Stafeful, no transaction and persist entity with generatedValue for ID : javax.transaction.InvalidTransactionException: Cannot resume foreign transaction: null
Description
Here my use case : I have
a Service entity :
Service.java
a ServiceSF / ServiceSFImpl stateful :
ServiceSFImpl.java
a test
Test.java
When I launch it, persist method raise an exception : javax.transaction.InvalidTransactionException: Cannot resume foreign transaction: null . After looking the code, I saw that hibernate starts a new transaction to get the generated ID, and then resume the previous transaction. But in my case there is no transaction, and Hibernate throw an InvalidTransactionException.
Here the complete stack trace :
Bar.java
Activity
Brett MeyerMarch 7, 2014 at 5:31 PM
Bulk closing rejected tickets in "resolved" state.
Strong LiuOctober 31, 2011 at 10:59 AM
not a bug
Chris BonamiOctober 6, 2011 at 1:55 PM
I have +/- same problem.
Most probably related to the use of TableGenerator.
See javadoc MultipleHiLoPerTableGenerator:
A hilo <tt>IdentifierGenerator</tt> that returns a <tt>Long</tt>, constructed using
a hi/lo algorithm. The hi value MUST be fetched in a seperate transaction
to the <tt>Session</tt> transaction so the generator must be able to obtain
a new connection and commit it. Hence this implementation may not
be used when the user is supplying connections. In this
case a <tt>SequenceHiLoGenerator</tt> would be a better choice (where
Here my use case :
I have
a Service entity :
Service.java
a ServiceSF / ServiceSFImpl stateful :
ServiceSFImpl.java
a test
Test.java
When I launch it, persist method raise an exception : javax.transaction.InvalidTransactionException: Cannot resume foreign transaction: null .
After looking the code, I saw that hibernate starts a new transaction to get the generated ID, and then resume the previous transaction. But in my case there is no transaction, and Hibernate throw an InvalidTransactionException.
Here the complete stack trace :
Bar.java