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.
是否可以仅使用注释将继承的字段在继承类中标记为唯一?对我来说,钟摆更偏向 NO 一侧,但想确认
您可以使用注释的uniqueConstraints属性:@Table
uniqueConstraints
@Table
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"thecolumn"})})
请注意,如果您没有使用 SINGLE_TABLE 继承策略的多个实体,这只会对您有用。