-
Jul 13th, 2011, 01:19 PM
#1
Using nested transaction with JPA
I want to use nested transaction using spring's declarative transaction management. I am using JPA transaction manager which doesn't support nested transaction (propagation). Even JTA implemeations like Atomikos don't support it. It seems like only transaction manager I can use is DataSourceTransactionManager (which I am not sure if I can use with JPA).
Can anybody suggest any alternatives to use spring's declarative tx management for nested transactions or way to simulate the nested transaction without NESTED propagation level.
thanks
-
Jul 13th, 2011, 04:12 PM
#2
EJB3 doesn't support NESTED in @TransactionAttribute so I would guess the brick wall you are hitting is due to other providers implementing the modes required for EJB3 support.
Since you are on a spring forum... is it a requirement to get JPA transaction semantics ? Which JPA provider are you using, would there be any issue with your project to consider dropping strict JPA compliance ? If seems you have a requirement (for NESTED support) that JPA as a standard doesn't support anyway.
You could setup your DAOs to bind with a specific JPA implemenation using their native interface and use their matching Spring transactionManager implementation. I would expect the providers to have a JPA API is still available, inter-operable and mixable.
-
Jul 14th, 2011, 04:05 PM
#3
We are using Eclipselink JPA provider. Currently we use JPATransactionManager and the only transaction manager which supports Nested is DataSourceTransactionManager. I tried using two different transaction managers (Switching to DataSourceTransactionManager in case of the NESTED requirement for a method) but couldn't get it to work.
I guess I have two questions now:
1. DO you know if there is any plans to implement Nested by any of the JPA providers ? if yes, I can get some workaround for now.
2. Till we get the final solution from JPA provider, is there any way to mimic the Nested behavior ? I could use Required propagation and have inner transaction to catch the exceptions instead of propagating it to the parent which will make ROLLBACK of the inner similar to the NESTED but COMMIT of inner can't be controlled. Since in NESTed case, COMMIT of the inner will happen only after parent is successful .
Appreciate your inputs.
Thanks
-
Jul 21st, 2011, 01:01 AM
#4
Any suggestions ?? mimicking nested behavior using other propagation levels ? Or intercepting @transaction call and avoid commit or rollback of the inner transaction ? that way inner tx will participate in the outer transaction for commit but rollback as an independent inner transaction in case inner tx failure.
Spring documentation talks about customizing/intercepting @transaction using aspects. Is there any examples which I can refer to?
Appreciate your help,
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules