[hibernate-issues] [Hibernate-JIRA] Created: (EJB-382) PersistenceException instead of EntityExistsException thrown when entity already exists
Miro Bezjak (JIRA)
noreply at atlassian.com
Sat Sep 6 17:50:04 EDT 2008
PersistenceException instead of EntityExistsException thrown when entity already exists
---------------------------------------------------------------------------------------
Key: EJB-382
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-382
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.4.0.GA
Reporter: Miro Bezjak
Priority: Minor
Attachments: hibernate.zip
By specification of EntityManager (http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#persist(java.lang.Object)) an EntityExistsException should be thrown when entity already exists but current implementation of AbstractEntityManagerImpl throws PersistenceException. I noticed the bug when upgrading from 3.3.2.GA (throws EntityExistsException properly) to 3.4.0.GA. It seems that problem is in throwPersistenceException method. 3.3.2.GA has following code:
"
else if ( e instanceof ConstraintViolationException ) {
//FIXME this is bad cause ConstraintViolationException happens in other circumstances
throwPersistenceException( new EntityExistsException( e ) );
}
"
but that was dropped in 3.4.0.GA (maybe because of http://opensource.atlassian.com/projects/hibernate/browse/EJB-349 ?).
Anyway, stack trace for attached example:
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert: [test.User]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list