Analyze org. hibernate. HibernateException: No Session found for current thread, getcurrentsession
/**
*
* Org. hibernate. HibernateException: No Session found for current thread
* Analysis: getCurrentSession () is related to the current transaction.
*
* Spring hibernate transaction process
*
* 1. Before the method starts
* ①. Get the Session
* ②. Bind the Session to the current thread so that the SessionFactory
* The getCurrentSession () method is used to obtain the Session.
* ③. Start the transaction
*
* 2. perform business operations
* 1) an exception occurs.
* ①. Roll back the transaction
* 2) normal termination
* ①. Submit the transaction
* Finally {
* ②. Unbind the Session bound to the current thread
* ③. Close the Session
*}
*
* Conclusion:
* If getCurrentSession () is used to obtain the Session
* ① Transactions must be configured
* ② All business methods must be included in the transaction attribute Configuration
*/