Home Answers Viewqa Hibernate Hibernate session.refresh() method

 
 


Rahul Dev
Hibernate session.refresh() method
1 Answer(s)      2 years and 7 months ago
Posted in : Hibernate

What is session.refresh() in hibernate?

View Answers

October 26, 2010 at 4:16 PM


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);









Related Pages:

Ask Questions?

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.