You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The convertHibernateAccessException() method in SessionFactoryUtils does not properly chain the source HibernateException into the transformed Spring IncorrectResultSizeDataAccessException.
if (ex instanceof NonUniqueResultException) {
return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1);
}
The root HibernateException is swallowed, and along with it the stack trace with the actual line of code that generated the Hibernate error. This makes it nearly impossible to debug these failures.
The rest of the 'if' branches in convertHibernateAccessException() do appear to be properly chaining the underlying HibernateException into the newly constructed Exception:
if (ex instanceof PropertyValueException) {
return new DataIntegrityViolationException(ex.getMessage(), ex);
}
if (ex instanceof PersistentObjectException) {
return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
}
Thanks, Eric. A new InvalidResultSizeDataAccessException constructor has been added that accepts and propagates the wrapped exception appropriately. Both SessionFactoryUtils as well as EntityManagerUtils have been updated to make use of it.
Note that this issue won't be available in nightly snapshots until #12721 is resolved.
Activity
spring-projects-issues commentedon Mar 22, 2011
Chris Beams commented
Thanks, Eric. A new
InvalidResultSizeDataAccessExceptionconstructor has been added that accepts and propagates the wrapped exception appropriately. BothSessionFactoryUtilsas well asEntityManagerUtilshave been updated to make use of it.Note that this issue won't be available in nightly snapshots until #12721 is resolved.