Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
@NaturalId在 Hibernate 中,我可以使用实体的多个属性创建唯一键。
@NaturalId
是否有 JPA 等效注释,它是其中的一部分javax.persistence?
javax.persistence
我通常做的是在列上添加一个唯一约束,使用@Table(uniqueConstraints = @UniqueConstraint(columnNames={column_1, ..., column_n}))
@Table(uniqueConstraints = @UniqueConstraint(columnNames={column_1, ..., column_n}))
不,那里没有。您将不得不使用复合键,因此EmbeddedId或IdClass取决于您的喜好。