Announcement Announcement Module
Collapse
No announcement yet.
Hibernate getCurrentSession/openSession Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate getCurrentSession/openSession

    Hi,

    just one simple question (as usual ;-)). In order to provide a valid session for my database transactions, I'm currently using the openSession() to create a session. However, is this the best pratice? What's the difference between openSession() and getCurrentSession() in terms of ressources and performance?

    Thanks in advance for your comments

    Michael

  • #2
    I think they are intended for different purposes. SessionFactory.openSession will do exactly that open a new session. Session.getCurrentSession is going to give you the currently open session in that context.

    http://www.hibernate.org/hib_docs/v3...l#openSession()
    http://www.hibernate.org/hib_docs/v3...urrentSession()

    Comment

    Working...
    X