ExceptionConverterImpl was swallowing some root cause exceptions
This commit is contained in:
parent
b208755db9
commit
d4ed740e38
|
@ -115,22 +115,22 @@ public class ExceptionConverterImpl implements ExceptionConverter {
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
else if ( exception instanceof ObjectNotFoundException ) {
|
else if ( exception instanceof ObjectNotFoundException ) {
|
||||||
final EntityNotFoundException converted = new EntityNotFoundException( exception.getMessage() );
|
final EntityNotFoundException converted = new EntityNotFoundException( exception.getMessage(), exception );
|
||||||
rollbackIfNecessary( converted );
|
rollbackIfNecessary( converted );
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
else if ( exception instanceof org.hibernate.NonUniqueObjectException ) {
|
else if ( exception instanceof org.hibernate.NonUniqueObjectException ) {
|
||||||
final EntityExistsException converted = new EntityExistsException( exception.getMessage() );
|
final EntityExistsException converted = new EntityExistsException( exception.getMessage(), exception );
|
||||||
rollbackIfNecessary( converted );
|
rollbackIfNecessary( converted );
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
else if ( exception instanceof org.hibernate.NonUniqueResultException ) {
|
else if ( exception instanceof org.hibernate.NonUniqueResultException ) {
|
||||||
final NonUniqueResultException converted = new NonUniqueResultException( exception.getMessage() );
|
final NonUniqueResultException converted = new NonUniqueResultException( exception.getMessage(), exception );
|
||||||
rollbackIfNecessary( converted );
|
rollbackIfNecessary( converted );
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
else if ( exception instanceof UnresolvableObjectException ) {
|
else if ( exception instanceof UnresolvableObjectException ) {
|
||||||
final EntityNotFoundException converted = new EntityNotFoundException( exception.getMessage() );
|
final EntityNotFoundException converted = new EntityNotFoundException( exception.getMessage(), exception );
|
||||||
rollbackIfNecessary( converted );
|
rollbackIfNecessary( converted );
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
@ -189,44 +189,44 @@ public class ExceptionConverterImpl implements ExceptionConverter {
|
||||||
return sharedSessionContract.getJdbcServices().getSqlExceptionHelper().convert( e, message );
|
return sharedSessionContract.getJdbcServices().getSqlExceptionHelper().convert( e, message );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PersistenceException wrapStaleStateException(StaleStateException e) {
|
protected PersistenceException wrapStaleStateException(StaleStateException exception) {
|
||||||
if ( e instanceof StaleObjectStateException ) {
|
if ( exception instanceof StaleObjectStateException ) {
|
||||||
final StaleObjectStateException sose = (StaleObjectStateException) e;
|
final StaleObjectStateException sose = (StaleObjectStateException) exception;
|
||||||
final Object identifier = sose.getIdentifier();
|
final Object identifier = sose.getIdentifier();
|
||||||
if ( identifier != null ) {
|
if ( identifier != null ) {
|
||||||
try {
|
try {
|
||||||
final Object entity = sharedSessionContract.internalLoad( sose.getEntityName(), identifier, false, true);
|
final Object entity = sharedSessionContract.internalLoad( sose.getEntityName(), identifier, false, true);
|
||||||
if ( entity instanceof Serializable ) {
|
if ( entity instanceof Serializable ) {
|
||||||
//avoid some user errors regarding boundary crossing
|
//avoid some user errors regarding boundary crossing
|
||||||
return new OptimisticLockException( e.getMessage(), e, entity );
|
return new OptimisticLockException( exception.getMessage(), exception, entity );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new OptimisticLockException( e.getMessage(), e );
|
return new OptimisticLockException( exception.getMessage(), exception );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (EntityNotFoundException enfe) {
|
catch (EntityNotFoundException enfe) {
|
||||||
return new OptimisticLockException( e.getMessage(), e );
|
return new OptimisticLockException( exception.getMessage(), exception );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new OptimisticLockException( e.getMessage(), e );
|
return new OptimisticLockException( exception.getMessage(), exception );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new OptimisticLockException( e.getMessage(), e );
|
return new OptimisticLockException( exception.getMessage(), exception );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PersistenceException wrapLockException(HibernateException e, LockOptions lockOptions) {
|
protected PersistenceException wrapLockException(HibernateException exception, LockOptions lockOptions) {
|
||||||
if ( e instanceof OptimisticEntityLockException ) {
|
if ( exception instanceof OptimisticEntityLockException ) {
|
||||||
final OptimisticEntityLockException lockException = (OptimisticEntityLockException) e;
|
final OptimisticEntityLockException lockException = (OptimisticEntityLockException) exception;
|
||||||
return new OptimisticLockException( lockException.getMessage(), lockException, lockException.getEntity() );
|
return new OptimisticLockException( lockException.getMessage(), lockException, lockException.getEntity() );
|
||||||
}
|
}
|
||||||
else if ( e instanceof org.hibernate.exception.LockTimeoutException ) {
|
else if ( exception instanceof org.hibernate.exception.LockTimeoutException ) {
|
||||||
return new LockTimeoutException( e.getMessage(), e, null );
|
return new LockTimeoutException( exception.getMessage(), exception, null );
|
||||||
}
|
}
|
||||||
else if ( e instanceof PessimisticEntityLockException ) {
|
else if ( exception instanceof PessimisticEntityLockException ) {
|
||||||
final PessimisticEntityLockException lockException = (PessimisticEntityLockException) e;
|
final PessimisticEntityLockException lockException = (PessimisticEntityLockException) exception;
|
||||||
if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) {
|
if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) {
|
||||||
// assume lock timeout occurred if a timeout or NO WAIT was specified
|
// assume lock timeout occurred if a timeout or NO WAIT was specified
|
||||||
return new LockTimeoutException( lockException.getMessage(), lockException, lockException.getEntity() );
|
return new LockTimeoutException( lockException.getMessage(), lockException, lockException.getEntity() );
|
||||||
|
@ -235,18 +235,18 @@ public class ExceptionConverterImpl implements ExceptionConverter {
|
||||||
return new PessimisticLockException( lockException.getMessage(), lockException, lockException.getEntity() );
|
return new PessimisticLockException( lockException.getMessage(), lockException, lockException.getEntity() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( e instanceof org.hibernate.PessimisticLockException ) {
|
else if ( exception instanceof org.hibernate.PessimisticLockException ) {
|
||||||
final org.hibernate.PessimisticLockException jdbcLockException = (org.hibernate.PessimisticLockException) e;
|
final org.hibernate.PessimisticLockException lockException = (org.hibernate.PessimisticLockException) exception;
|
||||||
if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) {
|
if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) {
|
||||||
// assume lock timeout occurred if a timeout or NO WAIT was specified
|
// assume lock timeout occurred if a timeout or NO WAIT was specified
|
||||||
return new LockTimeoutException( jdbcLockException.getMessage(), jdbcLockException, null );
|
return new LockTimeoutException( lockException.getMessage(), lockException, null );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new PessimisticLockException( jdbcLockException.getMessage(), jdbcLockException, null );
|
return new PessimisticLockException( lockException.getMessage(), lockException, null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new OptimisticLockException( e );
|
return new OptimisticLockException( exception );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue