我使用JoinColumn进行以下OneToMany UNI映射:
但在JPA wikibooks我读到这是错误的,如果是JoinColumn,则需要反向关系。我不明白为什么。我的代码有效。捕获的地方在哪里?
If the OneToMany uses a foreign key in the target object's table JPA requires that the
relationship be bi-directional (inverse ManyToOne relationship must be defined
in the target object), and the source object must use the mappedBy
attribute to define the mapping.
答案 0 :(得分:0)
效果提示:
根据Hibernate提交者Vlad Mihalcea的说法,最好使用双向实现: https://vladmihalcea.com/the-best-way-to-map-a-onetomany-association-with-jpa-and-hibernate/