要为2个diff diff列的组合添加唯一约束
There is no Hibernate annotation that checks uniqueness before insert/update. But there is annotation which will generate such a constraint to the database if automatic database creation is used:
Try this one: When hibernate create a table in DB create unique constraint combination of these two columns.
@Table(
name="Table_Name",
uniqueConstraints=
@UniqueConstraint(columnNames={"Column1", "Column2"})
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.