Hi Witold,
Toplink had that performance improvement (that has been removed at least in some
places where it proved to produce the wrong results) that a query at the
beginning of a transaction runs with a non-transactional connection. Can this be
the case? Which build are you using?
thanks,
-marina
Witold Szczerba wrote:
> Hi there,
> I have a scenario: one JDBC data source is used by two persistence
> units, each one in its own EJB module, both belongs to same enterprise
> application. First EJB module has "Session1" session bean and
> "method1" in it, second EJB module has "Session2" and "method2". Both
> methods have default transaction attribute (REQUIRED).
> Transaction begins in first EJB module:
>
> @Stateless
> public class Session1 implements Session1Local {
> @PersistenceContext EntityManager em;
> @EJB Session2Local session2;
>
> public void method1() {
> Person p = new Person();
> em.persist(p);
> em.flush();
> session2.method2();
> }
> }
>
> @Stateless
> public class Session2 implements Session2Local {
> @PersistenceContext EntityManager em;
>
> public void method2() {
> List persons = em.createQuery("SELECT p FROM Person p")
> .getResultList();
> // persons list does not contain the person persisted
> // in #method1 even though both methods are in the same transaction
> // and flush was explicitly invoked to synchronize first em's context
> }
> }
>
> My question is: why entity manager from EJB2 cannot see the person I
> just inserted into database? Both methods should be in THE SAME
> transaction, because both persistence units are JTA aware and are
> injected by application server itself.
>
> Why this does not work? Is the transaction from method1 not correctly
> propagated to method2?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>