I started using Hibernate and can any one explain how to handle Container Managed transaction. Here is my sample design
I have stateless session Bean and DAO (Hibernate) layer, session bean class has multiple DAO calls in a single session bean method. Reason behind Stateless session bean is to handle Container Managed Transaction. So Can any one help me how to handle CMT. How to create Hibernate Session, Can I use Session.openSession() or currentSession() ........... Provide some details on this.
You will still code the same way, with openSession() then beginTransaction(), and then commit()/rollback() and close() when you are done with the session. Hibernate is smart enough to use the CMT transaction, instead of creating its own Transaction object. So the commit() will not commit the CMT transaction, because there might be more stuff the CMT is doing, Hibernate is smart to do the right thing, so all you have to do is code it just like it wasn't in CMT, the code looks the exact same, no differences.