FileDocCategorySizeDatePackage
Transaction.javaAPI DocGlassfish v2 API6976Fri May 04 22:34:56 BST 2007com.sun.jdo.api.persistence.support

Transaction

public interface Transaction
The JDO Transaction interface is a sub-interface of the PersistenceManager that deals with options and completion of transactions under user control.

Transaction options include whether optimistic concurrency control should be used for the current transaction, and whether values should be retained in JDO instances after transaction completion.

Transaction completion methods have the same semantics as javax.transaction UserTransaction, and are valid only in the non-managed, non-distributed transaction environment.

author
Craig Russell
version
0.1

Fields Summary
Constructors Summary
Methods Summary
public voidbegin()
Begin a transaction. The type of transaction is determined by the setting of the Optimistic flag.

see
#setOptimistic
see
#getOptimistic
throws
JDOUserException if a distributed transaction XAResource is assigned to this Transaction

public voidcommit()
Commit the current transaction.

public booleangetNontransactionalRead()
If this flag is set to true, then queries and navigation are allowed without an active transaction

return
the value of the nontransactionalRead property.

public booleangetOptimistic()
Optimistic transactions do not hold data store locks until commit time.

return
the value of the Optimistic property.

public PersistenceManagergetPersistenceManager()
The Tranansaction instance is always associated with exactly one PersistenceManager.

return
the PersistenceManager for this Transaction instance

public intgetQueryTimeout()
Gets the number of seconds to wait for a query statement to execute in the datastore associated with this Transaction instance

return
timout value in seconds; zero means unlimited

public booleangetRestoreValues()
If true, at rollback time instances restore their field values.

return
the value of the restoreValues property

public booleangetRetainValues()
If true, at commit time instances retain their field values.

return
the value of the retainValues property

public javax.transaction.SynchronizationgetSynchronization()
The user-specified Synchronization instance for this Transaction instance.

return
the user-specified Synchronization instance.

public intgetUpdateTimeout()
Gets the number of seconds to wait for an update statement to execute in the datastore associated with this Transaction instance

return
timout value in seconds; zero means unlimited

public booleanisActive()
Returns whether there is a transaction currently active.

return
boolean

public voidrollback()
Roll back the current transaction.

public voidsetNontransactionalRead(boolean flag)
If this flag is set to true, then queries and navigation are allowed without an active transaction

param
flag the value of the nontransactionalRead property.

public voidsetOptimistic(boolean optimistic)
Optimistic transactions do not hold data store locks until commit time.

param
optimistic the value of the Optimistic flag.

public voidsetQueryTimeout(int timeout)
Sets the number of seconds to wait for a query statement to execute in the datastore associated with this Transaction instance

param
timeout new timout value in seconds; zero means unlimited

public voidsetRestoreValues(boolean restoreValues)
If true, at rollback instances restore their values and the instances transition to persistent-nontransactional.

param
restoreValues the value of the restoreValues property

public voidsetRetainValues(boolean retainValues)
If true, at commit instances retain their values and the instances transition to persistent-nontransactional.

Setting this flag also sets the NontransactionalRead flag.

param
retainValues the value of the retainValues property

public voidsetSynchronization(javax.transaction.Synchronization sync)
The user can specify a Synchronization instance to be notified on transaction completions. The beforeCompletion method is called prior to flushing instances to the data store.

The afterCompletion method is called after performing the data store commit operation.

param
sync the Synchronization instance to be notified; null for none

public voidsetUpdateTimeout(int timeout)
Sets the number of seconds to wait for an update statement to execute in the datastore associated with this Transaction instance

param
timeout new timout value in seconds; zero means unlimited