Reputation: 992
I have been using hibernate with Springs where i don't get to use getSession() or getCurrentSession() as the Spring container manages it.
But i came across this getSession() and getCurrentSession() methods while reading hibernate.
Can anyone explain when to use either of the methods?
Upvotes: 2
Views: 6581
Reputation: 104168
getCurrentSession is a method of the SessionFactory interface. As the name implies, an implementation of this method is responsible for creating and managing sessions. What does "current" mean, depends on the implementation.
A getSession method is usually used by classes that build wrappers around Hibernate (like Spring's HibernateDaoSupport).
I don't think that there is a class that implements both of these methods. You can't compare them outside of the context they are used and the classes that implement them.
Upvotes: 2