Using @Id for multiple fields in same class

后端 未结 1 627
别那么骄傲
别那么骄傲 2021-01-11 17:26

I am a newbie to Hibernate and have to support an existing application that uses Hibernate It is a pure reporting application - no insert / update / delete - only select

相关标签:
1条回答
  • 2021-01-11 18:03

    According to the Hibernate docs, Hibernate seems to allow this but it is not however JPA compliant.

    5.1.2.1.2. Multiple id properties without identifier type

    Another, arguably more natural, approach is to place @Id on multiple properties of your entity. This approach is only supported by Hibernate (not JPA compliant) but does not require an extra embeddable component.

    http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#d0e4819

    For a JPA compliant solution you would have to specify an additional @IDClass for this set-up (or use an EmbeddedId):

    http://www.objectdb.com/java/jpa/entity/id

    0 讨论(0)
提交回复
热议问题