Skip to content

SessionFactoryUtils.convertHibernateAccessException() improperly swallows underlying HibernateException [SPR-7933] #12588

Closed
@spring-projects-issues

Description

@spring-projects-issues

Eric Sirianni opened SPR-7933 and commented

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);
}

Affects: 3.0.5

Issue Links:

Referenced from: commits b0b1116

5 votes, 0 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions