Root cause not properly extracted when transaction commit fails

Description

I've got an exception without the proper cause, making it difficult to understand what happened:

Using a breakpoint in TransactionImpl I see wrappedException = e.getCause(); (line 70), which returns null.

In my case, the exception was javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session.
I assume a check should be done and use the exception itself if the cause is null.

Environment

None

Activity

Show:
Vlad Mihalcea
March 7, 2016, 5:42 PM

Sure. You need to extend org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase and supply the interceptor like this:

Vlad Mihalcea
March 8, 2016, 6:23 AM

I made a test and the interceptor doesn't work for this because all the exceptions are caught and don't cause a transaction failure. I'll cherry pick your change and create a test case and commit it like that.

Vlad Mihalcea
March 8, 2016, 7:46 AM

I created a new PR with both the fix and the test case.

Andrei Ivanov
March 8, 2016, 10:31 AM

Thank you

Vlad Mihalcea
March 9, 2016, 7:14 AM

Merged it into master and the 5.0 branch.

Fixed

Assignee

Vlad Mihalcea

Reporter

Andrei Ivanov

Fix versions

Labels

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure