Hibernate (Unable to instantiate default tuplizer [org.hibernate.tuple.entity.Po

tommy900705 2011-12-02 08:04:49
错误:Initial SessionFactory creation failed.org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
2011-12-2 0:50:53 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet NewContactServlet threw exception
java.lang.NullPointerException

我在网上查了很多,因为我的程序在改动之前是可以运行的,所以不存在少什么东西之类的,应该就是实体类中的XX属性和getXX方法对不上,这类的问题,但是我查了很久都不知道哪错了,再加上这块比较不熟……希望大家指正一下,最好能详细点,纯新手。谢谢

PhoneNumber.hbp.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="domain">
<class name="PhoneNumber" table="PhoneNumber_Table">
<id name="id_phone">
<generator class="increment"/>
</id>
<property name="phoneKind" type="string"></property>
<property name="phoneNumber" type="string"></property>

<many-to-one name="contact" class ="Contact" column="ID_CONTACT"></many-to-one>
</class>
</hibernate-mapping>

PhoneNumber.java

public class PhoneNumber {

long id_phone;
String phoneKind;
String phoneNumber;
// String phoneKind2;
// String phoneNumber2;
// String phoneKind3;
// String phoneNumber3;
Contact contact;

public PhoneNumber(){

}

public PhoneNumber(String phoneKind, String phoneNumber) {
super();
this.phoneKind = phoneKind;
this.phoneNumber = phoneNumber;

}

public long getid_phone() {
return id_phone;
}

public void setid_phone(long id_phone) {
this.id_phone = id_phone;
}

public String getPhoneKind() {
return phoneKind;
}

public void setPhoneKind(String phoneKind1) {
this.phoneKind = phoneKind1;
// this.phoneKind2 = phoneKind2;
// this.phoneKind3 = phoneKind3;
}

public String getPhoneNumber() {
return phoneNumber;
}

public void setPhoneNumber(String phoneNumber1) {
this.phoneNumber = phoneNumber1;
// this.phoneNumber2 = phoneNumber2;
// this.phoneNumber3 = phoneNumber3;
}


public Contact getContact() {
return contact;
}

public void setContact(Contact contact) {
this.contact = contact;
}


Contact.hbp.xml


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="domain">
<class name="Contact" table="Contact_Table">
<id name="id_contact" type="long" column="ID_CONTACT" >
<generator class="increment"/>
</id>
<property name="firstName" column="FirstName" ></property>
<property name="lastName" column="LastName" ></property>
<property name="email" column="Email" ></property>
<many-to-one name="address" column="ID_ADD" unique="true"></many-to-one>
<set name="phonenumber" inverse="true" >
<key column="ID_CONTACT"></key>
<one-to-many class="PhoneNumber"/>
</set>
<set name="contactgroups" inverse="true" table="jointable">
<key column="ID_CONTACT"></key>
<many-to-many class="ContactGroup" column="ID_ContactGroup"></many-to-many>
</set>
</class>
</hibernate-mapping>


相关的问价大概就是这些……希望大家能抽时间看看,谢谢!
...全文
401 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
licip 2011-12-02
  • 打赏
  • 举报
回复
楼上两位说的对。这是编码范围的问题
luckyc2008 2011-12-02
  • 打赏
  • 举报
回复
hibernate不能用id_phone,下划线吧,自动生成的是idPhone,好像变量用下划线不支持的
oO临时工Oo 2011-12-02
  • 打赏
  • 举报
回复
setter / getter方法肯定不对

long id_phone;

以下这样肯定不对
public long getid_phone() {}
public void setid_phone(long id_phone) {}

至少应该是

public long getId_phone() {}
public void setId_phone(long id_phone) {}

去了解一下javaBean的规范吧

如果在eclipse中,你完全可以用向导生成:在源代码文件中,右键->Source ->Generate getters and setters

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧