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

automatic Session context management

 
Steve Atkins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am a newbie. Anyone please help.

1. What does the below mentioned property setting imply?
2. What is the other option for automatic Session context management?

<!-- Enable Hibernate's automatic Session context management -->
<property name="current_session_context_class">thread</property>

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you create a hibernate session using any of the sessionFactory.openSession(...) methods the session factory will 'bind' the session to the current context. The default context is 'thread' which means the sesion factory will bind the session to the thread from which openSession(...) is called.

This is useful because you can later call sessionFactory.getCurrentSession() which will return the session that is bound to the currently running thread.

You can use other predefined current_session_context_class values such as 'jta' which will bind the session to the currently running JTA transaction (if you're running in an application server that supports JTA this is really useful). Or you can write your own implementation of org.hibernate.context.CurrentSessionContext and use that implementation to manage the current session context (not really advisable unless you absolutely need to).


Hibernate Forums

-Cameron McKenzie
 
Steve Atkins
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks cameroon.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic