Analysis Org.hibernate.HibernateException:No Session found for current thread

Source: Internet
Author: User

/**
*
* Org.hibernate.HibernateException:No Session found for current thread
* Analysis: Getcurrentsession () is related to the current transaction
*
* Process of Spring hibernate transaction
*
* 1. Before the method starts
*①. Getting session
*②. Bind the session to the current thread so that you can use the sessionfactory in the DAO
* Getcurrentsession () method to get the session
*③. Opening a transaction
*
* 2. Execution of Business methods
* 1) exception occurred
*①. Rolling back a transaction
* 2) Normal end
*①. Committing a transaction
* finally{
*②. Unbind the session with the current thread binding
*③. Closing session
*         }
*
* Conclusion:
* As long as you use Getcurrentsession () to get the session,
*① must configure the transaction
*② must include all business methods when configuring transaction properties

*/

Analysis Org.hibernate.HibernateException:No Session found for current thread

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.