db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guido Anzuoni <ganzu...@objectmagic.org>
Subject Re: enlistment of native connections for optimistic txs
Date Mon, 16 Apr 2007 11:39:21 GMT
Hi to all,
I agree that using datastore transaction term on the subject topic could
be very misleading.
What we are discussing here is the retain policy of the "connection" to
the native datastore the PM is applying.
According to Matthew proposal the result should be:

Connection getDataStoreConnection()

This method is equivalent to getDataStoreConnection 
(pm.currentTransaction().isActive()). That is, it defaults to  
getDataStoreConnection(true) if a JDO transaction is active, and  
getDataStoreConnection(false) if not.  

JDOConnection getDataStoreConnection(boolean enlist)

Regardless the type of transaction (optimistic or datastore),
if this method is called outside an active transaction, with the  
enlist parameter false, the object returned will be a brand new connection obtained from the
underlying datastore engine. If this method is called outside an active  
transaction, with the enlist parameter true, JDOUserException is thrown.

If this method is called inside an active transaction the behavior is the
following:
Case l enlist=false
the object returned will be a brand new connection obtained by the
underlying datastore engine. The PersistenceManager will never deliberately use 
the returned connection.

Case 2 enlist=true
If the PersistenceManager has already acquired a connection that it would use
for the rest of the transaction anyway, this connection is returned.
If the PersistenceManager has not acquired yet a connection that it would use
for the rest of the transaction, a new connection is obtained by the
underlying datastore engine and permanently assigned for the current transaction
management; this connection is then returned.


Guido.

Mime
View raw message