The use of Session in hibernate

1. Session fresh and refresh methods

 

  fresh: refresh the session cache and synchronize the data in the session to the database. When the transaction is submitted, the session's fresh method will be called first by default.

 

  refresh: Keep the cached data in the session consistent with the database.

 

2. save and persist

   Both save and persist are used to persist objects, but after setting the primary key generation method, if the saved POJO still has an ID, the save method will ignore the ID,

     And persist will throw an exception. 

 

 



 

   

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326522192&siteId=291194637