Today, I inserted a piece of data into my project. I thought this module was finally done. But I expected to see, "When I inserted a piece of data using hibernate, the database already exists and the app could not find it, after restarting tomcat, the app can query ".
At that time, my analysis was like this, because the database already exists and the Java program can be found after Tomcat is restarted, exclude uncommitted transactions (usually used for hibernate development because it is used to commit ). This may be because the session is not closed. The data obtained before Tomcat is closed is in the previous session, but the program code checks this assumption. I can see an introduction in this article. Now I will record it.
Add the following configuration in hibernate. cfg. XML (of course the corresponding jar should also be introduced, the version I use is c3p0-0.9.1.jar)
<Property name = "hibernate. Connection. provider_class"> org. hibernate. Connection. c3p0connectionprovider </property>
There will be other problems that cause this phenomenon, but I have used this method to solve my problem. If you still need to add it later. In addition, I did not continue to study this rack package. The role of this configuration should be noted down for future studies.
Note: This solution is found on the internet, but now the link address cannot be found, and it is recorded.