db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Bengtson <e...@jpox.org>
Subject enlistment of native connections for optimistic txs
Date Sun, 08 Apr 2007 20:49:13 GMT

Hi,

This is a change proposal to the spec with regards to enlistment of native
connections when optimistic transactions are used.

The enlistment of native connections into a JDO transaction is conditioned to
the fact that a flush call has been performed before the connection is
obtained.

The flush call is a JDO implementation decision which can differ between
different implementations. See the example:

1. tx.begin();
2. //more operations here....
3. JDOConnection conn = pm.getDataStoreConnection();
4. Connection sqlconn = (Connection) conn.getNativeConnection();
5. sqlconn.execute("DELETE FROM ANIMAL WHERE NAME = 'CAT'")
5. conn.close();
6. tx.rollback();

There are two possible behaviors:

- The JDO implementation decides to perform a flush between 1 and 3: the
connection is enlisted, and DELETE all CATS from ANIMAL is rolled back
- The JDO implementation decides to NOT perform a flush between 1 and 3: the
connection is not enlisted, and DELETE all CATS from ANIMAL is not rolled back

As you can see, this is not portable and not ACID, so I would like to propose
that enlistment of connections is done whenever a transaction is opened.

The change is to the following paragraph:

The JDO spec ยง12.16 - getDataStoreConnection:

"If this method is called while a datastore transaction is active, the object
returned will be enlisted in the current transaction. If called in an
optimistic transaction before flush has been called, or outside an active
transaction, the object returned will not be enlisted in any transaction."

AS:

"If this method is called while a datastore or optimistc transaction is active,
the object returned will be enlisted in the current transaction. If called
outside an active transaction, the object returned will not be enlisted in any
transaction."



Mime
View raw message