我有两个类映射到OneToMany,ManyToOne,我得到异常:
org.hibernate.AnnotationException:mappedBy引用未知的目标实体属性: entity_package.UserEntity.ownedTickets中的entity_package.TicketEntity.ownerEntity
这是代码:
公共类UserEntity实现Serializable {
@OneToMany(mappedBy="ownerEntity")
public List<TicketEntity> getOwnedTickets() {
return tickets;
}
public void setOwnedTickets(List<TicketEntity> tickets) {
this.tickets = tickets;
}
和......
公共类TicketEntity实现Serializable {
private UserEntity ownerEntity;
@ManyToOne
@JoinColumn(name="owner_id")
public UserEntity getOwner() {
return ownerEntity;
}
public void setOwner(UserEntity owner) {
this.ownerEntity = owner;
}
怎么了?
答案 0 :(得分:4)
属性名称为owner
,由带注释的getter定义。使用:
@OneToMany(mappedBy="owner")
public List<TicketEntity> getOwnedTickets() {