public RuntimeException convert(HibernateException e, LockOptions lockOptions) {
if(!isJpaBootstrap && is51ExceptionCompatibilityRequired){
if ( e instanceof QueryException || e instance of MultipleBagFetchException ) {
return e;
}
else {
try {
sharedSessionContract.markForRollbackOnly();
}
catch (Exception ne) {
log.unableToMarkForRollbackOnTransientObjectException( ne );
}
return e;
}
}
else{
Throwable cause = e;
if ( cause instanceof StaleStateException ) {
final PersistenceException converted = wrapStaleStateException( (StaleStateException) cause );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof LockAcquisitionException ) {
final PersistenceException converted = wrapLockException( (HibernateException) cause, lockOptions );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof LockingStrategyException ) {
final PersistenceException converted = wrapLockException( (HibernateException) cause, lockOptions );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof org.hibernate.PessimisticLockException ) {
final PersistenceException converted = wrapLockException( (HibernateException) cause, lockOptions );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof org.hibernate.QueryTimeoutException ) {
final QueryTimeoutException converted = new QueryTimeoutException( cause.getMessage(), cause );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof ObjectNotFoundException ) {
final EntityNotFoundException converted = new EntityNotFoundException( cause.getMessage() );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof org.hibernate.NonUniqueObjectException ) {
final EntityExistsException converted = new EntityExistsException( cause.getMessage() );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof org.hibernate.NonUniqueResultException ) {
final NonUniqueResultException converted = new NonUniqueResultException( cause.getMessage() );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof UnresolvableObjectException ) {
final EntityNotFoundException converted = new EntityNotFoundException( cause.getMessage() );
handlePersistenceException( converted );
return converted;
}
else if ( cause instanceof QueryException ) {
return new IllegalArgumentException( cause );
}
else if ( cause instanceof MultipleBagFetchException ) {
return new IllegalArgumentException( cause );
}
else if ( cause instanceof TransientObjectException ) {
try {
sharedSessionContract.markForRollbackOnly();
}
catch (Exception ne) {
log.unableToMarkForRollbackOnTransientObjectException( ne );
}
return new IllegalStateException( e ); }
else {
final PersistenceException converted = new PersistenceException( cause );
handlePersistenceException( converted );
return converted;
}
}
}