As per our application design, we have been Hibernate EntityManager 3.2.1 in Weblogic Server 10.0.
We do have an EmployeeMaster table where the unique constraint is applied on the Employee 'FIRSTNAME' field of this table. The Employee ID field has been designated as the primary key over here.
While trying to persist a duplicate employee entity (with the same 'FIRSTNAME' that is already as part of the table), the hibernate entity manager seems to throw only the 'org.hibernate.exception.ConstraintViolationException' whereas we were looking for an EntityExistsException as per the documentation.
I have also attached my code snippet below for your reference:
public <T extends PersistenceObject> T create(T pObject) throws LMSException {
try {
this.getEntityManager().persist(pObject);
}
catch (EntityExistsException aEntityExistsException) {
System.out.println("Duplicate Entity Exception:"+aEntityExistsException);
}
return pObject;
}
Can you kindly help me out on how to sort out this issue?
Regards,
Sathish
|