You're right - I guess I got the wrong idea about persistence contexts.
First of all, the problem I tried to explain is solved - with the TransactionAttribute REQUIRES_NEW used in Bean (A) the EntityManager in (B) does not return null anymore. I thought I was testing this attribute before I posted my question, but obviously I did not or I made some other mistake... sorry for that!
Now there's much less need for a shared persistence context... what I was expecting from sharing persistence context was that it could make the application faster by doing less commits and instead using the shared context (or a shared EntityManager) as some kind of cache. Í did not realize that this idea would not work when there's more than one virtual machine (or, maybe, expecting that the EntityManager will take care of all of that...). Our application might not be typically for J2EE - in fact, transactions are not very important, because data is written only once but than read/queried often, so it would not be neccessary to store it in the database as long as there is enough RAM available - under these circumstances it could make sense to share data that only has been persisted by an EntityManager, but not yet committed to the db, over several parallel working MDBs.
Thanks for the time you spend in reading strange newbie questions,
Stephan
|