Avi K.
Avi K.

Reputation: 655

NHibernate update POCO from different session

We load POCO using nhibernate, close the session and then update it (add items to bag or change some properties) and finally create a new session and update it.
How does NHibernate know how to update the changes? (maybe something like select and compare the updated item with the previous one?)

Upvotes: 0

Views: 111

Answers (1)

moribvndvs
moribvndvs

Reputation: 42497

When you use Merge or the likes, it will attempt to resolve the persistent object with one it already knows about, and if it doesn't, it will load it from the database. At that point, NHibernate has the load state, as well as the current state, and will compare the values between the two states to see if it is dirty. If it is dirty, it can/will flush the changes.

Upvotes: 1

Related Questions