Hi,
Trying to get to grips with a "open session in view" approach, and the mixture of that with transactions.
It appears I have to tell Hibernate which transaction strategy I want. For example, if I use Hibernate's local transaction strategy then I have to, in my action, get the transaction from Hibernate's session, do the work, then commit the transaction. Yes? That seems to work for me.
If however I set something like:
Code:
hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.WeblogicTransactionManagerLookup
then I am unsure when the transaction begins and ends. From my logs, it seems to end when the session is closed, so I guess it begins when the session is opened? So I don't have to explicitly demarcate the transaction? (ie. I don't have to find usertransaction in JNDI and begin it? When I did, I got an error). It seems to work if I don't begin it myself. Automagically its happening under the hood, which is confusing me - so I don't quite know when to explicilty begin/commit it - if at all....
But this all leads to the next thing - if I use the open session in view, so that the session extends across all actions (and other things such as EJB's as I'm using hte thread local pattern), then the session will only be closed when after the JSP page is generated - which means that I think the JTA transaction will extend that long too - which seems like bad practice...
Any pointers?
Thanks
J