1

I have a Hibernate Session and quered an Object. I then commit the transaction and end the session. I now have a detached Object. If I now start another session and transaction and need my detached object as an input parameter for another query I usually do:

session.update(<detachedObject>)

But then also an update query is triggered while my object hasn't changed. I know why Hibernate does this and I'm fine with that...

However, might it be more performant/best practice to just re-query my detached object in the new session to use as an input parameter for my query and therefore also avoid the update statement? Or does anyone has a better idea on how to implement this kind of behavior?

bvanvelsen - ACA Group
  • 1,741
  • 1
  • 14
  • 25
  • Have you looked at session.refresh() and session.merge()? [here](http://stackoverflow.com/a/1070629/690553) is a good place to read too. – Amir Pashazadeh Dec 03 '12 at 10:01

0 Answers0