Reputation: 4187
So i have one EJB EjbA
and a hibernate entity named EntityA
.
EnitityA
has property EnitityB
and some String
type properties.
EjbA
has method methodA
which manipulate EnitityA
.
Now if i call a methodA
of EjbA
, the manipulate done on EnitityA
will be reflected in db after the EJB call gets finish.
I know that when we call EJB method we actually call a proxy implementation on it which first start the db transaction, open hibernate session....
But
How does it call hibernate.update
on the EntityA
that has been changed in the method call ? basically how does ejb container knows that only entityA has been modified in this EJB method call ?
Upvotes: 0
Views: 111
Reputation: 960
When you load an entity with find() or some other query it gets into Managed state. It is bound with particular session and when the session is being closed/flushed entities bound with it are getting updated (therefore all modifications will be propagated into DB). And updating of HasA relationships (entityB within entityA) of the entities being updated depends on the cascade settings.
Upvotes: 1