HHH-17163 throw EntityExistsException as required by JPA spec 3.2.2
This commit is contained in:
parent
87fe5fbde4
commit
4e1f4aeeb7
|
@ -13,6 +13,7 @@ import org.hibernate.HibernateException;
|
|||
import org.hibernate.JDBCException;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.ObjectNotFoundException;
|
||||
import org.hibernate.PersistentObjectException;
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.TransientObjectException;
|
||||
|
@ -120,7 +121,8 @@ public class ExceptionConverterImpl implements ExceptionConverter {
|
|||
rollbackIfNecessary( converted );
|
||||
return converted;
|
||||
}
|
||||
else if ( exception instanceof org.hibernate.NonUniqueObjectException ) {
|
||||
else if ( exception instanceof org.hibernate.NonUniqueObjectException
|
||||
|| exception instanceof PersistentObjectException) {
|
||||
final EntityExistsException converted = new EntityExistsException( exception.getMessage(), exception );
|
||||
rollbackIfNecessary( converted );
|
||||
return converted;
|
||||
|
|
|
@ -8,9 +8,10 @@ package org.hibernate.orm.test.ops;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import jakarta.persistence.EntityExistsException;
|
||||
import jakarta.persistence.PersistenceException;
|
||||
|
||||
import org.hibernate.PersistentObjectException;
|
||||
import org.hibernate.dialect.AbstractHANADialect;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
|
@ -187,9 +188,9 @@ public class CreateTest extends AbstractOperationTestCase {
|
|||
session.persist( dupe );
|
||||
fail( "Expecting failure" );
|
||||
}
|
||||
catch (PersistenceException e) {
|
||||
catch (Exception e) {
|
||||
//verify that an exception is thrown!
|
||||
assertTyping( PersistentObjectException.class, e );
|
||||
assertTyping( EntityExistsException.class, e );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -203,9 +204,9 @@ public class CreateTest extends AbstractOperationTestCase {
|
|||
session.persist( nondupe );
|
||||
fail( "Expecting failure" );
|
||||
}
|
||||
catch (PersistenceException e) {
|
||||
catch (Exception e) {
|
||||
//verify that an exception is thrown!
|
||||
assertTyping( PersistentObjectException.class, e );
|
||||
assertTyping( EntityExistsException.class, e );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue