开发者

JPA unique constraint validation

开发者 https://www.devze.com 2023-03-05 10:27 出处:网络
How to validate Multiple column unique constraint in JPA entity. Is there any Hibernate validator for this purpose. I have added @UniqueConstraint annotation. But it is not doing any validation.And I开

How to validate Multiple column unique constraint in JPA entity. Is there any Hibernate validator for this purpose. I have added @UniqueConstraint annotation. But it is not doing any validation.And I开发者_运维技巧 also want to customize the error message.


The @UniqueConstraint is not related to hibernate-validator. It cannot be handled by java-only validation, it needs a trip to the database.

It tells hibernate that the database has a unique constraint. If the database does not have a unique constraint, I think the insert should pass.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号