Unique JPA constraint check

How to check the multiple restriction on the uniqueness of columns in a JPA entity. There is a Hibernate validator for this purpose. I added the @UniqueConstraint annotation. But he does not do any verification. And I also want to customize the error message.

+3
source share
1 answer

@UniqueConstraintnot associated with hibernate-validator. It cannot be processed only by checking only in Java, it needs a trip to the database.

He tells hibernate that the database has a unique limitation. If the database does not have a unique constraint, I think the insert should go through.

+7
source

All Articles