geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Transactions and DB Pools in JPA
Date Wed, 09 Aug 2006 00:38:05 GMT

On Aug 8, 2006, at 5:27 PM, Dain Sundstrom wrote:

> If this is for 1.1, you need to demarcate the transactions using  
> the TransactionContextManager.  I suggest you take a look at the  
> OnlineUserTransaction for a good example.

IMNSHO container managed jta aint gonna work for 1.1 since it NEEDS  
the new jta interface to be able to flush the cache before the tx  
commits.

App managed JPA ought to be ok, just stay away from jta.
As dblevins said, the jpa implementation will be managing the tx  
locally on the jdbc connection by turning off autocommit and ending  
the tx with conn.commit().  This should all work fine (even with a  
localtx or xa pool) so long as you don't have any jta activity in  
sight.  As soon as you start an jta tx the jdbc resource adapter  
ought to start complaining vociferously.

thanks
david jencks



>
> -dain
>
> On Aug 8, 2006, at 4:28 PM, Aaron Mulder wrote:
>
>> OK, so for this JPA plugin, the goal is to support application- 
>> managed
>> JPA for web apps.
>>
>> It looks like a JPA EntityManager has a call to getTransaction
>> returning an EntityTransaction which you can used to begin and commit
>> transactions in the non-JTA case (which, for now, let's assume this
>> would be).
>>
>> So I'm thinking the code would look like this:
>>
>> EntityManager mgr = ...
>> EntityTransaction tx = mgr.getTransaction();
>> tx.begin();
>> // save some JPA changes
>> tx.commit();
>>
>> There was a comment that we shouldn't used Geronimo DB pools with  
>> JPA,
>> which I don't follow.  What is the suggested way to hook the JPA
>> provider up to the database?  It looks like you provide a
>> PersistenceUnitInto with methods getJtaDataSource and
>> getNonJtaDataSource...  I don't know which one of these a Geronimo DB
>> pool would be.  Does it depend on whether the pool claims to support
>> none, local, or XA transactions?
>>
>> Also, I guess I need to figure out whether we could be in the JTA  
>> case
>> -- I'm not sure if supplying a JTA DataSource is enough.  Maybe then
>> the code would look like this:
>>
>> UserTransaction tx = ...
>> tx.begin();
>> // save some JPA changes
>> tx.commit();
>>
>> I'll keep reading the JPA spec, but in the mean time, if anyone has a
>> full understanding of this, some insight would be great.
>>
>> Thanks,
>>     Aaron
>


Mime
View raw message