JPA equivalent to Hibernate's @NaturalId

后端 未结 2 364
梦如初夏
梦如初夏 2020-12-31 10:38

In Hibernate I can create a unique key using @NaturalId on several properties of the entity.

Is there a JPA equivalent annotation, something that is a p

相关标签:
2条回答
  • 2020-12-31 11:16

    No, there is not. You will have to use composite keys, so either EmbeddedId or IdClass depending what you prefer.

    0 讨论(0)
  • 2020-12-31 11:19

    What I usually do is add a unique constraint on the columns, using @Table(uniqueConstraints = @UniqueConstraint(columnNames={column_1, ..., column_n}))

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