且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

引起原因:org.hibernate.AnnotationException:maptedBy引用了未知的目标实体属性:

更新时间:2023-01-08 18:44:28

消息非常清晰.您是对JPA说的:这个OneToMany是Delivery实体中通过字段deliveries定义的ManyToOne的反面.但是Delivery中没有字段deliveries.交付中的相应字段名为purveyor:

The message is pretty clear. You're saying to JPA: this OneToMany is the inverse side of the ManyToOne, defined in the Delivery entity, by the field deliveries. But there is no field deliveries in Delivery. The corresponding field in Delivery is named purveyor:

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "ref_purveyor")
private Purveyor purveyor;
                   ^-- this is the other side of the association

所以您需要的是

@OneToMany(fetch=FetchType.LAZY,mappedBy = "puveyor")