Sunday, September 1, 2013

Difference between getCurrentSession and opensession


getCurrentSession():
 A Session is opened when getCurrentSession() is called for the first time and closed when the transaction ends.
The "current session" refers to a Hibernate Session bounded by Hibernate behind the scenes, to the transaction scope.
openSession():
If you decide to use manage the Session yourself the go for sessfac.openSession(), you have to flush() and close() it. It does not flush and close() automatically.