Reputation: 1377
I have a for loop that calls another method which saves the data to a temporary table using hibernate. After the for loop, I have a code that calls a stored procedure to copy the data that was saved from the temporary table to the live table. However, the stored procedure is being called first before hibernate starts saving the data even if the code for saving the data is before the stored procedure. So when I query the live table, the data were not there. Is there a way to wait for hibernate to complete updating before i call the stored procedure? Hibernate seems to wait for the for loop to finish first before it updates the database which is probably why when i call the stored procedure the result was empty. Can anyone help on how i can address this delay? thanks a lot.
here is my code:
for(Object1 obj: obj1List){
saveHibernateObj(obj);
}
getCurrentSession().createSQLQuery("Call update_object()").executeUpdate();
Upvotes: 2
Views: 1384
Reputation: 888
You should make a hibernare session flush by calling session.flush() method before calling stored procedure
Upvotes: 2