使用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方法都去掉也报同样的错误