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.
如何验证 JPA 实体中的多列唯一约束。是否有任何用于此目的的 Hibernate 验证器。我添加了 @UniqueConstraint 注释。但它没有做任何验证。我也想自定义错误消息。
与休眠验证器@UniqueConstraint无关。它不能由纯 java 验证处理,它需要访问数据库。
@UniqueConstraint
它告诉 hibernate 数据库有一个唯一的约束。如果数据库没有唯一约束,我认为插入应该通过。