Originally posted by kri shan:
Hi Mark, As per scenario our trasaction spans two classes(DAO's). Can i pass the same session to another DAO or create new session in another DAO? Here both(DAOs) are different table CRUD operations.
Can i commit at the end of the transaction or using different commit for each DAO?
This is what sessionFactory.getCurrentSession() does for you. You need that session to span two DAOs, getCurrentSession() will create a Session for you if one doesn't already exist. If one already exists, it returns that one. It stores the Session into the ThreadLocal. Check out the ThreadLocal javadocs for more information on how that works.
Mark