What is session.refresh() in hibernate?
It is possible to re-load an object and all its collections at any time, using the refresh() method. This is useful when database triggers are used to initialize some of the properties of the object.
For Example - Triger on catname coulmn. Trigger is updating hitcount coulmn in the same Cat Table. When Insert data into Cat TABLE trigger update hit_count coulmn to 1. session.refresh() reload all the data. No nned again to select call.
session.save(cat); session.flush(); //force the SQL INSERT session.refresh(cat); //re-read the state (after the trigger executes);
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.