A problem occurred in the project a few days ago: When submitting data on the page, the following error occurs: cocould not toggle autocommit, org. hibernate. sessionexception: Session is close.
The project structure is spring + hibernate.
The following describes how to handle the problem:
Solution 1
I found a buddy on the internet saying that he wants to change the configuration file:
Remove Connection. autocommit = true of hibernate. cfg. xml ....
I checked the configuration file and did not set this item. This solution does not suit my situation.
Solution 2
Find a Robbin article on the Internet about how to analyze transaction in hibernateArticle
URL: http://www.javaeye.com/topic/264#806
After reading it, I learned the bottom layer of hibernate.Code.
Solution 3
No way. I checked my code again and carefully. We found that:
After opensession () is followed by closesession (), this should be caused by a mistake in writing code. It is too careless!
After modification, the problem does not recur.
Reflection:
1. Being careful is very important. As the saying goes, Details determine success or failure.
2 open-source frameworks such as Hibernate and spring should be consciously viewed in applicationsSource codeTo understand the underlying