table-per-class

Java/Hibernate JPA: InheritanceType.TABLE_PER_CLASS and IDs

北城余情 提交于 2019-11-27 06:32:39
问题 I'm using Hibernate JPA. Suppose I have these classes: AbstractPerson |--> ConcreteEmployee |--> ConcreteCustomer Is there any way to make the concrete classes have independent IDs? I'm using InheritanceType.TABLE_PER_CLASS. 回答1: From the Hibernate Annotations Reference Guide: 2.2.4.1. Table per class This strategy has many drawbacks (esp. with polymorphic queries and associations) explained in the JPA spec, the Hibernate reference documentation, Hibernate in Action, and many other places.