使用hibernate annotation在继承过程中出现Unable to instantiate default tuplizer,找了一天都没找到问题

wdl5i 2010-03-29 08:20:30
请教高手CompanyCustomer从Customer继承,但是启动tomcat6的时候出现Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer],不知道是怎么回事?多谢
Customer.java

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="discriminator",
discriminatorType=DiscriminatorType.STRING
)
@DiscriminatorValue("customer")
public class Customer {

private int id;
private Customer parent;

public String getCategory(){
return "未知";
}

@Id
@GeneratedValue
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

@ManyToOne
@JoinColumn(name="pid")
public Customer getParent() {
return parent;
}

public void setParent(Customer parent) {
this.parent = parent;
}
}



CompanyCustomer.java
@Entity
@DiscriminatorValue("company")
public class CompanyCustomer extends Customer {

//人员规模
private String employeeSize;

@Column(insertable=false,updatable=false)
public String getCategory(){
return "公司";
}

public String getEmployeeSize() {
return employeeSize;
}

public void setEmployeeSize(String employeeSize) {
this.employeeSize = employeeSize;
}
}


Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property category in class com.wdl.crm.model.PersonalCustomer

不写这一句@Column(insertable=false,updatable=false)
则会出现重复映射的问题,不知道怎么解决,找了一天都没找到问题出在哪里,和没有setCategory方法没关系,因为我在父类和子类把getCategory方法都去掉也报同样的错误
...全文
950 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
karali 2012-07-29
  • 打赏
  • 举报
回复
我遇到过这样的问题:是因为配置文件里多出了一个一对多的配置,我把它删了,问题就解决了。
liufeng0209 2010-09-14
  • 打赏
  • 举报
回复
我觉得,使用单表继承怎么也没有多表继承好,单表继承存在数据冗余,如果子类还有关联关系会更加麻烦.
建议换一种继承方式吧
wp315157110 2010-09-12
  • 打赏
  • 举报
回复
我也碰到了同样的问题。。杯具

67,514

社区成员

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

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