As we know, when doing a bulk update to the DB with hibernate (even in HQL), the changes made are not replicated to the entities stored in the current session.

So i may call session.refresh to load the modifications to my session entities.

We often call flush for sending our modifications to the DB, but the documentation say it "synchronize" the session and the db...

Does that mean that flush will be able to set the good new db value to my session entity? Or flush will eventually erase my new db value with the old one stored in the entity? (Btw if hibernate's behaviour is the 1st one, how does it detect which one is the "good value"?).

If i can't use flush on such a case, it is a good practice to clear the session after each bulk update so that we are sure to have good values in our session?

Edit
Report