org.jpox.resource
Class JdoTransactionHandle

java.lang.Object
  extended byorg.jpox.resource.JdoTransactionHandle
All Implemented Interfaces:
javax.resource.cci.LocalTransaction, Transaction, javax.jdo.Transaction

public class JdoTransactionHandle
extends java.lang.Object
implements Transaction, javax.resource.cci.LocalTransaction

JdoManagedTransaction.java Implementations of the methods simply hand off to the transaction of the PM.

Version:
$Revision: 1.9 $

Constructor Summary
JdoTransactionHandle(PersistenceManagerImpl pm)
          Constructor
 
Method Summary
 void begin()
          Begin the transaction.
 void commit()
          Commit the transaction.
 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.
 boolean getNontransactionalRead()
          Accessor for non-transactional reads
 boolean getNontransactionalWrite()
           
 boolean getOptimistic()
          Accessor for the optimistic transactions flag
 javax.jdo.PersistenceManager getPersistenceManager()
          Accessor for the persistence manager.
 boolean getRestoreValues()
          Accessor for whether to restore values
 boolean getRetainValues()
          Accessor for whether to retain values
 boolean getRollbackOnly()
          Accessor for the "rollback only" flag.
 javax.transaction.Synchronization getSynchronization()
          Accessor for the synchronization
 int getTransactionIsolation()
          Accessor for the transaction isolation level.
 boolean isActive()
          Accessor for whether the transaction is active.
 boolean isCommitting()
          Accessor for whether the 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 rollback()
          Perform rollback of the transaction
 void setNontransactionalRead(boolean ntr)
          Mutator for non-transactional reads
 void setNontransactionalWrite(boolean ntw)
          Mutator for non-transactional writes
 void setOptimistic(boolean optimistic)
          set the optimistic transactions flag
 void setRestoreValues(boolean restore_values)
          Mutator for whether to restore values
 void setRetainValues(boolean retain_values)
          Set retainValues flag
 void setRollbackOnly()
          Mutator for the "rollback only" flag.
 void setSynchronization(javax.transaction.Synchronization synch)
          Set the synchronization.
 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdoTransactionHandle

public JdoTransactionHandle(PersistenceManagerImpl pm)
Constructor

Parameters:
pm - the PersistenceManager
Method Detail

begin

public void begin()
Begin the transaction.

Specified by:
begin in interface javax.jdo.Transaction

commit

public void commit()
Commit the transaction.

Specified by:
commit in interface javax.jdo.Transaction

rollback

public void rollback()
Perform rollback of the transaction

Specified by:
rollback in interface javax.jdo.Transaction

isActive

public boolean isActive()
Accessor for whether the transaction is active.

Specified by:
isActive in interface javax.jdo.Transaction
Returns:
Whether the txn is active

isCommitting

public boolean isCommitting()
Accessor for whether the transaction is committing.

Specified by:
isCommitting in interface Transaction
Returns:
Whether the txn is committing

getRollbackOnly

public boolean getRollbackOnly()
Accessor for the "rollback only" flag.

Specified by:
getRollbackOnly in interface javax.jdo.Transaction
Returns:
The rollback only flag

setRollbackOnly

public void setRollbackOnly()
Mutator for the "rollback only" flag.

Specified by:
setRollbackOnly in interface javax.jdo.Transaction

setNontransactionalRead

public void setNontransactionalRead(boolean ntr)
Mutator for non-transactional reads

Specified by:
setNontransactionalRead in interface javax.jdo.Transaction
Parameters:
ntr - Whether to use nontransactional reads

getNontransactionalRead

public boolean getNontransactionalRead()
Accessor for non-transactional reads

Specified by:
getNontransactionalRead in interface javax.jdo.Transaction
Returns:
Whether to use nontransactional reads

setNontransactionalWrite

public void setNontransactionalWrite(boolean ntw)
Mutator for non-transactional writes

Specified by:
setNontransactionalWrite in interface javax.jdo.Transaction
Parameters:
ntw - Whether to use nontransactional writes

getNontransactionalWrite

public boolean getNontransactionalWrite()
Specified by:
getNontransactionalWrite in interface javax.jdo.Transaction
Returns:
Whether to use nontransactional writes

setRetainValues

public void setRetainValues(boolean retain_values)
Set retainValues flag

Specified by:
setRetainValues in interface javax.jdo.Transaction
Parameters:
retain_values -

getRetainValues

public boolean getRetainValues()
Accessor for whether to retain values

Specified by:
getRetainValues in interface javax.jdo.Transaction
Returns:
Whether to retain values

setRestoreValues

public void setRestoreValues(boolean restore_values)
Mutator for whether to restore values

Specified by:
setRestoreValues in interface javax.jdo.Transaction
Parameters:
restore_values - Whether to restore values

getRestoreValues

public boolean getRestoreValues()
Accessor for whether to restore values

Specified by:
getRestoreValues in interface javax.jdo.Transaction
Returns:
Whether to restore values

setOptimistic

public void setOptimistic(boolean optimistic)
set the optimistic transactions flag

Specified by:
setOptimistic in interface javax.jdo.Transaction
Parameters:
optimistic -

getOptimistic

public boolean getOptimistic()
Accessor for the optimistic transactions flag

Specified by:
getOptimistic in interface javax.jdo.Transaction
Returns:

setSynchronization

public void setSynchronization(javax.transaction.Synchronization synch)
Set the synchronization.

Specified by:
setSynchronization in interface javax.jdo.Transaction
Parameters:
synch -

getSynchronization

public javax.transaction.Synchronization getSynchronization()
Accessor for the synchronization

Specified by:
getSynchronization in interface javax.jdo.Transaction
Returns:

getPersistenceManager

public javax.jdo.PersistenceManager getPersistenceManager()
Accessor for the persistence manager.

Specified by:
getPersistenceManager in interface javax.jdo.Transaction
Returns:

getConnection

public java.sql.Connection getConnection(boolean forWriting,
                                         boolean forQuery)
                                  throws java.sql.SQLException
Description copied from interface: Transaction
Accessor for the connection to the datasource.

Specified by:
getConnection in interface Transaction
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
Description copied from interface: Transaction
Accessor for the connection to the datasource.

Specified by:
getConnection in interface Transaction
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()
Description copied from interface: Transaction
Checks whether a connection to the datasource is open.

Specified by:
isConnectionOpen in interface Transaction
Returns:
true if the Connection is open

releaseConnection

public void releaseConnection(java.sql.Connection conn)
                       throws java.sql.SQLException
Description copied from interface: Transaction
Method to release the Connection.

Specified by:
releaseConnection in interface Transaction
Parameters:
conn - The Connection to release.
Throws:
java.sql.SQLException - Thrown when an error occurs releasing the connection.

getTransactionIsolation

public int getTransactionIsolation()
Description copied from interface: Transaction
Accessor for the transaction isolation level.

Specified by:
getTransactionIsolation in interface Transaction
Returns:
The transaction isolation level.

setTransactionIsolation

public void setTransactionIsolation(int isolationLevel)
Description copied from interface: Transaction
Mutator for the transaction isolation level.

Specified by:
setTransactionIsolation in interface Transaction
Parameters:
isolationLevel - The isolation level required.

useUpdateLockOnFetch

public boolean useUpdateLockOnFetch()
Description copied from interface: Transaction
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.

Specified by:
useUpdateLockOnFetch in interface Transaction
Returns:
Whether to use an update lock.

setUseUpdateLock

public void setUseUpdateLock(boolean lock)
Description copied from interface: Transaction
Mutator for whether to lock queried/fetched objects in this txn.

Specified by:
setUseUpdateLock in interface Transaction
Parameters:
lock - Whether to use an update lock.

getJDOConnection

public javax.jdo.datastore.JDOConnection getJDOConnection()
Description copied from interface: Transaction
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?

Specified by:
getJDOConnection in interface Transaction
Returns:
The Connection


Copyright © -2007 . All Rights Reserved.