Reputation: 863
How does hibernate identify that a given object is detached?
I understand the fact that when the session closes all the entity objects associated with that session gets detached. But what is the thing which makes us say that a given object is detached.
Like for example while differentiating between transient entity object and persistent, we can say transient object does not have the id value populated and the persistent object does not have it.
Upvotes: 0
Views: 90
Reputation: 29837
Hibernate, and quite a few of other ORMs, implement a pattern called Unit Of Work. In this pattern, the unit of work keeps a reference to all the attached objects (so if an object is not in that set, then it's not attached).
In hibernate, the Session is the unit of work which tracks which objects are attached.
Upvotes: 1