我有一个带有辅助方法的Entity类。喜欢这个..
@Entity
@Table(name = "MEMBER", schema = "APP_SCHEMA")
public class Member {
private String id;
private String externalMemberId;
@Id
@Column(name = "MEMBER_ID")
public String getId() {
return id;
}
@Column(name = "EXTERNAL_MEMBER_ID")
public String getExternalMemberId() {
return externalMemberId;
}
public String getAbc(){
return "abc";
}
}
初始化
时启动jboss服务器时出现异常Caused by: javax.persistence.PersistenceException: [PersistenceUnit: DataDB] Unable to build EntityManagerFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
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 **abc** in class com.myapp.model.Member"}}
为什么它不允许我在实体类中有辅助/方便的方法?为什么期望与财产映射?我正在使用JBoss app服务器与Hibernate和JPA。
答案 0 :(得分:1)
Hibernate将您的getter方法getAbc()
解释为应该保留的abc
属性的getter。您可以使用@Transient
注释来标记它不应存储在数据库中的字段。或者尝试将注释放在getter方法的字段中。