3p0 current_session_context_class 属性解释

<property name="hibernate.current_session_context_class">jta</property>

<property name="hibernate.current_session_context_class">thread</property>

 

jta / thread 的选择

 

参考原文地址:https://forums.hibernate.org/viewtopic.php?p=2384980&sid=55c82c31f846749e5aa7fa38b8657a03

 

Hi,

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).

Neil

你可能感兴趣的:(thread,Hibernate,PHP)