Hibernate cannot obtain MySQL database updates in real time. hibernatemysql
Hibernate has been used in recent projects, but after each database record is updated, the updated data cannot be found with hibernate. I found many tutorials on the Internet, and finally found that it can be solved by changing the default connection pool of hibernate. By using the c3p0 connection pool and replacing the default hibernate connection pool, you can find the MySQL updated data.
The specific modification method is as follows:
Add the following content to the hibernate. cfg. xml configuration file:
<Property name = "hibernate. connection. provider_class "> org. hibernate. connection. c3P0ConnectionProvider </property> <property name = "hibernate. c3p0. max_size "> 20 </property> <! -- Maximum number of available database connections in the connection pool --> <property name = "hibernate. c3p0. min_size"> 5 </property> <! -- The minimum number of available database connections in the connection pool --> <property name = "hibernate. c3p0. max_statements "> 100 </property> <property name =" hibernate. c3p0. idle_test_period "> 120 </property> <property name =" hibernate. c3p0. acquire_increment "> 1 </property> <property name =" c3p0. testconnectioncheckout "> true </property> <property name =" c3p0. idleConnectionTestPeriod "> 18000 </property> <property name =" c3p0. maxIdleTime "> 25000 </property>
The jar package of c3p0,: http://download.csdn.net/detail/until_v/8149191