[
http://opensource.atlassian.com/projects/hibernate/browse/EJB-382?page=co...
]
Felipe Jaekel commented on EJB-382:
-----------------------------------
In my case any exception is thrown, even with Core 3.2.6 + EntityManager 3.3.2 , so I get
a javax.ejb.EJBException: Transaction aborted; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
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
Assignee: Hardy Ferentschik
Priority: Critical
Fix For: 3.4.1
Attachments: hibernate.zip
By specification of EntityManager
(
http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.htm...)
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira