[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openejb-development
Subject:    jpa joinTransaction
From:       "Karan Malhi" <karan.malhi () gmail ! com>
Date:       2008-06-15 13:01:41
Message-ID: ac85de250806150601p4a45be6ehfbe21625f7fa99c6 () mail ! gmail ! com
[Download RAW message or body]


Please look at this issue here

http://www.nabble.com/JPA%2C-entities-and-EJB3-tp17502079s134p17798289.html

The scenario is that two RESOURCE_LOCAL entity managers are obtained and
they join a JTA transaction.  Since both the EM's have their own cache,
modification to the same entity in the two caches does not guarantee which
Entity managers entity will be flushed to the database.

I think that when two or more RESOURCE_LOCAL entity managers join a JTA
transaction, they should refer to a shared persistence context i.e. they
should behave like TRANSACTION EM's. This way the above scenario will not be
possible (and there will not be any ambiguities). However, there is a little
problem with this approach i.e.

Lets assume that there is a row in a database with one column. The value in
that column is "x"
EM1 reads the row and creates entity1 in it cache
EM2 reads the row and creates entity1 in its cache
EM2 modifies entity1 and stores "y" in it
EM1 joins the transaction
EM2 joins the transaction

In the above case, the PersistenceContext cache would need to be merged into
one. What should be in the cache ("x" or "y" ).

Does anybody see any other issues with RESOURCE_LOCAL entity managers
sharing a Persistence Context ? If not, do you think something like the
above should be proposed for the next release of JPA (if it hasn't already
been taken care of)?
-- 
Karan Singh Malhi


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic