-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Andreas Benneke opened SPR-13243 and commented
We are using JPA (Hibernate 4) with Spring 4 managing the JTA transactions. To allow lazy initialization even when simply reading from the database without any transaction we added the "OpenEntityManager" pattern.
We know that there is a difference between having no transaction synchronization at all and SUPPORTS synchronization. But the JPA behaviour seems to be inconsistent somehow:
- If there is no transaction synchronization active, we get a TransactionRequiredException from Springs SharedEntityManagerCreator when trying to persist something using JPA.
- If there is only a SUPPORTS transaction synchronization active, we don't get this exception and the persist request is silently ignored. This however is exactly the situation to avoid in the SharedEntityManagerCreator when creating the above exception.
- If there is an "OpenEntityManager" pattern active, there is no exception also and the persist request is silently ignored as well.
In my opinion there is no real difference between these situations and I would expect to see this exception in all cases or none?
You can find a test case for these questions on GitHub https://github.com/abenneke/sandbox/tree/master/spring-hibernate4-transaction
Affects: 4.1.7
Reference URL: http://stackoverflow.com/questions/27346975
Issue Links:
- Shared EntityManager should immediately throw TransactionRequiredException if no transaction in progress [SPR-11923] #16541 Shared EntityManager should immediately throw TransactionRequiredException if no transaction in progress
- Transaction propagation SUPPORTS leads to “HHH000326: Cannot join transaction” warning [SPR-13242] #17833 Transaction propagation SUPPORTS leads to “HHH000326: Cannot join transaction” warning
- Shared EntityManager's target lookup doesn't work with Spring Data's ChainedTransactionManager [SPR-14371] #18944 Shared EntityManager's target lookup doesn't work with Spring Data's ChainedTransactionManager
- Regression: Shared EntityManager proxy insists on actualTransactiveActive flag even with SYNCHRONIZATION_NEVER [SPR-13838] #18411 Regression: Shared EntityManager proxy insists on actualTransactiveActive flag even with SYNCHRONIZATION_NEVER
Referenced from: commits 7e2a662, fca33f5
0 votes, 5 watchers