EJB programming & troubleshooting: Transactions
Hello all, Scenario-1 SLSB1 - m1() calls SLSB2 - m2(). Both these methods use Hibernate to make calls to the Database. Scenario-2 SFSB1 - m1() calls SLSB2 - m2(). Both these methods use Hibernate to make calls to the Database. Whats the best way to handle transactions in these 2 scenarios? m1() and m2() use their own hibernate sessions to set and get data. I want m2() to run within the transaction context of m1(). Replies appreciated ! Thanks
I wud suggest you to demarcate your transactions through EJB CMT and do not rely on Hibernate for managing ur transactions in both the cases. You wud be using JTA to manage ur transactions. You can do this in ejb-jar.xml. Let me know is this gives u enough hint to move forward or u need more help. Thanks
You can use commands to wrap the resources like sessions and transactions. Read at the http://fishbolt.org/java/org.fishbolt.common/doc/article.en.html#CommandPattern. The fishbolt (http://fishbolt.org) projects also have a hibernate specific implementation at the http://fishbolt.org/java/org.fishbolt.hibernate/doc/description.en.html (details you can read at the http://fishbolt.org/java/org.fishbolt.hibernate/doc/article.en.html#Architecture.