I have a 3rd party library that starts a transaction via JTA directly and then invokes a class of my own on two separate occassions (but within the same overall JTA transaction). This custom class of my own is supplied by Spring and is wrapped in a Spring transaction aspect. Spring, using its own JtaTransactionManager, then participates in the surrounding JTA transaction. My custom class uses a DAO that is further wrapped in the Spring Hibernate3 aspect (which ensures that my DAO always uses the same Hibernate Session for the duration of the transaction, amongst other things).
Could someone tell me what Spring is supposed to do with the Hibernate Session between calls to my custom class? I would think that since Spring is participating in a surrounding JTA transaction, that it would create a new Session on the first invocation but not close it when that first invocation returns so that it could then reuse that same Session for the second invocation, finally closing the Session when the 3rd party library commits the surrounding JTA transaction. However, it appears that Spring is creating two separate Sessions, once for each invocation.
I've done some initial testing, and it looks like Spring does not create two separate Sessions if Spring's JtaTransactionManager is driving the overall transaction - but if the 3rd party is driving the overall transaction via JTA directly, then I'm out of luck?