DataIntegrityViolationException « Exception « JPA Q&A





1. discriminating between DataIntegrityViolationException    forum.hibernate.org

I am using Spring with Hibernate to persist User entities. Users have roles and attributes. The Users table has many-to-many relationships with the Roles table and with the Attributes table. There are several cases in which I get a DataIntegrityViolationException while saving a User: - when trying to persist a User with an already existing userName (violation of UNIQUE constraint) - ...