Bhuvan
Bhuvan

Reputation: 4187

How EntityManager works inside EJB 3.0 context, but not outside EJB context

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

Answers (1)

TechCrap
TechCrap

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

Related Questions