Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

open sessions vs cuurent session

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What is the difference between opensession and getCurrentSession. I was expecting a true as I thought getcurrentsession was returning me the already opened session in previous line
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getCurrentSession() returns the session associated with the transaction the method is running in. This is likely to have been opened by an interceptor before you called openSession().
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I wrote this from the main method. I dont think there is any interceptor.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you'll be getting whatever session is associated with the CurrentSessionContext configured for the SessionFactory. Be aware that what you are trying to do is not how getCurrentSession() is intended to be used.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is current session context ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic