I'm using JTA in my Hibernate application, and following the reference docs everything is working fine within JBoss.
I'm wondering, though, how can I use two separate transactions (EG: bound to separate connections, so that commit() on one doesn't affect the other) within the JTA environment.
Reading JTA docs I see that the UserTransaction is bound to the current thread, so there can be only one - I guess.
I need to the following :
- Begin TX1
- Do some stuff in TX1
- Obtain a value from the DB which needs updating a row, and must be done ANYWAY, even if TX1 fails, to prevent duplicate value. So i should start TX2, obtain the value, update, commit TX2.
- Do other stuff in TX1
- Commit TX1
I can't isolate TX2. I know that in EJB a REQUIRES_NEW concept exists. How can I replicate the same behaviour with Hibernate/JTA *without* using EJBs ?
Thanks in advance.
Giulio
|