Or hibernate. current_session_context_class in spring

Source: Internet
Author: User
In the sessionfactory configuration file of SSH2
Set hibernate. current_session_context_class to org. springframework. Orm. hibernate3.springsessioncontext (default value)
And apply spring to manage transactions.
If it is <prop key = "hibernate. current_session_context_class"> thread </prop>, an exception is reported,
In the source code of spring class localsessionfactorybean
In method buildsessionfactory
If (isexposetransactionawaresessionfactory () {<br/> // set hibernate 3.1 + currentsessioncontext implementation, <br/> // providing the spring-managed session as current session. <br/> // can be overridden by a custom value for the corresponding hibernate property. <br/> config. setproperty (<br/> environment. current_session_context_class, springsessioncontext. class. getname (); <br/>}< br/> If (this. jtat Ransactionmanager! = NULL) {<br/> // set spring-provided JTA transactionmanager as Hibernate property. <br/> config. setproperty (<br/> environment. transaction_strategy, jtatransactionfactory. class. getname (); <br/> config. setproperty (<br/> environment. transaction_manager_strategy, localtransactionmanagerlookup. class. getname (); <br/>}< br/> else {<br/> // makes the hibernate session aware of the presence of a spring-managed transaction. <br/> // also sets connection release mode to on_close by default. <br/> config. setproperty (<br/> environment. transaction_strategy, springtransactionfactory. class. getname (); <br/>}
Set
Hibernate. current_session_context_class is set to org. springframework. Orm. hibernate3.springsessioncontext

Springsessioncontext
Implementation of hibernate 3.1's currentsessioncontext interface that
Delegates to spring's sessionfactoryutils for providing a spring-managed current
Session.

Used by spring'sLocalSessionFactoryBean

When told to expose a transaction-aware sessionfactory. This is the default
Of Spring 2.5.

This currentsessioncontext implementation can also be specified in custom
Sessionfactory setup through the "hibernate. current_session_context_class"
Property, with the fully qualified name of this class as value.

public class SpringSessionContext






Extends object

Implements org. hibernate. Context. currentsessioncontext

Implementation of hibernate 3.1's currentsessioncontext Interface
That delegates to spring's sessionfactoryutils for providing
Spring-managed current session.

Used by spring'sLocalSessionFactoryBean

When told to expose
Transaction-aware sessionfactory. This is the default as of spring 2.5.

This currentsessioncontext implementation can also be specified in custom
Sessionfactory setup through the "hibernate. current_session_context_class"
Property, with the fully qualified name of this class as value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.