users@glassfish.java.net

basic question to lifecyle entitymanager

From: <glassfish_at_javadesktop.org>
Date: Thu, 26 Jun 2008 01:13:49 PDT

Hi,

two basic question to lifecyle of an entitymanager:

SessionBean1+2: Required-Transaction context, stateless Beans, running in glassfish, toplink-persistence.

Szenario:

step 0) client (outside container) calls a datacreation-method of sessionBean1.create(data)

step 1) sessionBean1 (without entitymanager injection) delegates for data-creation a call to

step 2) sessionBean2.create(data), which has an injected entitymanager and em.create(data)
     to JTA-persistenceUnit, returns the new, managed data to
step 3) sessionBean1, with modifies the data.setValue("new value") and
step 4) leave the container (=end transaction) and returns to the client.

** Question1: Why is the database modified to "new value" ?
The entitymanager instance, injected in step 2 is destroy (is it ?), beacause
leaving the stateless sessionbean2 ?

** Question2: If i inject a entitymanager in SessionBean1 step 1), is this the same instance of the entitymanager as the instance injected in step2 to SessionBean2 ?
So, if i inject Enitiymanagers in every Bean(required-transactions) in the CallFlow - is it always the same entitymanager ?

regards
Danny
[Message sent by forum member 'danny70437' (danny70437)]

http://forums.java.net/jive/thread.jspa?messageID=282702