我有两个表vehicleregister
和groupdetails
,因为我有VehicleRegisterBean
和GroupDetails
公用字段是groupid
的bean。在这里,一组可以包含许多我正在执行的一对多关系的车辆,因为我将bean定义为:
VehicleRegiserBean,
@Entity
@Table(name = "vehicle_register")
public class VehicleRegisterBean {
// somefields
@ManyToOne
@JoinColumn(name="groupid", nullable=false)
private GroupDetails groupDetails;
//getter setters
}
和
组详细信息,
@Entity
@Table(name = "group_details")
public class GroupDetails {
//some fields
@OneToMany(mappedBy="GroupDetails")
private Set<VehicleRegisterBean> vehicleRegisterBean;
//getters setters
}
但我得到了例外,
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.abc.its.beans.VehicleRegisterBean.GroupDetails in com.abc.its.beans.GroupDetails.vehicleRegisterBean
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:685)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:645)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1716)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
谁能帮我解决这个问题。
最佳答案
mappedBy
属性的值表示VehicleRegisterBean
类中的字段,该字段是groupDetails
,但是您正在GroupDetails
中使用mappedBy
。
因此,hibernate试图在GroupDetails
中查找属性VehicleRegisterBean
,并说它无法找到该属性。那就是错误的意思:
mappedBy reference an unknown target entity property:
com.abc.its.beans.VehicleRegisterBean.GroupDetails