org.jpox
Interface Transaction

All Superinterfaces:
javax.jdo.Transaction
All Known Implementing Classes:
JdoTransactionHandle

public interface Transaction
extends javax.jdo.Transaction

Extension of SUN's JDO Transaction.

Version:
$Revision: 1.9 $

Method Summary
 java.sql.Connection getConnection(boolean forWriting, boolean forQuery)
          Accessor for the connection to the datasource.
 java.sql.Connection getConnection(boolean forWriting, boolean forQuery, boolean useOpenedConnection)
          Accessor for the connection to the datasource.
 javax.jdo.datastore.JDOConnection getJDOConnection()
          Accessor for the connection to the datasource.
 int getTransactionIsolation()
          Accessor for the transaction isolation level.
 boolean isCommitting()
          Checks whether a transaction is committing.
 boolean isConnectionOpen()
          Checks whether a connection to the datasource is open.
 void releaseConnection(java.sql.Connection conn)
          Method to release the Connection.
 void setTransactionIsolation(int isolationLevel)
          Mutator for the transaction isolation level.
 void setUseUpdateLock(boolean lock)
          Mutator for whether to lock queried/fetched objects in this txn.
 boolean useUpdateLockOnFetch()
          Accessor for whether to use an update lock when fetching data.
 
Methods inherited from interface javax.jdo.Transaction
begin, commit, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getPersistenceManager, getRestoreValues, getRetainValues, getRollbackOnly, getSynchronization, isActive, rollback, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setRestoreValues, setRetainValues, setRollbackOnly, setSynchronization
 

Method Detail

getConnection

public java.sql.Connection getConnection(boolean forWriting,
                                         boolean forQuery)
                                  throws java.sql.SQLException
Accessor for the connection to the datasource.

Parameters:
forWriting - Whether the connection is read-only or read-write.
forQuery - Whether the connection is to be used by a query (i.e.JDOQUERY).
Returns:
The Connection
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(boolean forWriting,
                                         boolean forQuery,
                                         boolean useOpenedConnection)
                                  throws java.sql.SQLException
Accessor for the connection to the datasource.

Parameters:
forWriting - Whether the connection is read-only or read-write.
forQuery - Whether the connection is to be used by a query (i.e.JDOQUERY).
useOpenedConnection - whether to use an already opened connection, if one is opened.
Returns:
The Connection
Throws:
java.sql.SQLException

isConnectionOpen

public boolean isConnectionOpen()
Checks whether a connection to the datasource is open.

Returns:
true if the Connection is open

isCommitting

public boolean isCommitting()
Checks whether a transaction is committing.

Returns:
Whether the transaction is committing

releaseConnection

public void releaseConnection(java.sql.Connection conn)
                       throws java.sql.SQLException
Method to release the Connection.

Parameters:
conn - The Connection to release.
Throws:
java.sql.SQLException - Thrown when an error occurs releasing the connection.

getTransactionIsolation

public int getTransactionIsolation()
Accessor for the transaction isolation level.

Returns:
The transaction isolation level.

setTransactionIsolation

public void setTransactionIsolation(int isolationLevel)
Mutator for the transaction isolation level.

Parameters:
isolationLevel - The isolation level required.

useUpdateLockOnFetch

public boolean useUpdateLockOnFetch()
Accessor for whether to use an update lock when fetching data. Will return false if isolation levels of TRANSACTION_REPEATABLE_READ or TRANSACTION_SERIALIZABLE are selected. Otherwise returns the local settings of the useUpdateLock flag.

Returns:
Whether to use an update lock.

setUseUpdateLock

public void setUseUpdateLock(boolean lock)
Mutator for whether to lock queried/fetched objects in this txn.

Parameters:
lock - Whether to use an update lock.

getJDOConnection

public javax.jdo.datastore.JDOConnection getJDOConnection()
Accessor for the connection to the datasource. 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 or outside an active transaction, the object returned will not be enlisted in any transaction. The object must be returned to the JDO implementation prior to calling any JDO method or performing any action on any persistent instance that might require the JDO implementation to use a connection. If the object has not been returned and the JDO implementation needs a connection, a JDOUserException is thrown. The object is returned to the JDO implementation by calling the standard method on the object. //TODO understand better the JDO spec //TODO if the object not enlisted is not closed, raise an exception?

Returns:
The Connection


Copyright © -2007 . All Rights Reserved.