Hello!
I am using Hibernate Annotations 3.3.0 GA and Hibernate Core 3.2.5.GA with a MySQL 5 database.
One of my object attributes is annotated with
@Column(nullable = false, unique = true)
public String getPath() { ... }
and the MySQL table definition accordingly says
UNIQUE KEY `path` (`path`)
When I try to persist an object with an existing value for 'path' I get a ConstraintViolation, which is the correct and expected behavior.
I wonder, however, why I get a org.hibernate.exception.ConstraintViolationException instead of a javax.persistence.EntityExistsException.
My application consistently uses the EJB3 persistence API and no Hibernate-specific API calls. Why is a Hibernate exception thrown in an EJB3-only environment?
Thank you and best regards, Uwe
|