Oracle Application Server TopLink API Reference
10g Release 2 (10.1.2)

B15903-01


oracle.toplink.jdo
Class JDOTransaction

java.lang.Object
  extended byoracle.toplink.jdo.JDOTransaction

All Implemented Interfaces:
javax.jdo.Transaction

public class JDOTransaction
extends java.lang.Object
implements javax.jdo.Transaction

JDO wrapper for a TopLink unit of work.


Method Summary
void begin()
Begin a transaction.
void commit()
Commit the current transaction.
boolean getNontransactionalRead()
When the nontransactional read flag is set to false the PersistenceManager has a single TopLink UnitOfWork associated with it.
boolean getNontransactionalWrite()
If true, allows persistent instances to be written without a transaction active.
boolean getOptimistic()
Optimistic transactions do not hold data store locks until commit time.
javax.jdo.PersistenceManager getPersistenceManager()
The Tranansaction instance is always associated with exactly one PersistenceManager.
boolean getRetainValues()
If true, at commit time instances retain their field values.
javax.transaction.Synchronization getSynchronization()
The user-specified Synchronization instance for this Transaction instance.
UnitOfWork getUnitOfWork()
Return the associated TopLink unit of work.
boolean isActive()
Returns whether there is a transaction currently active.
void rollback()
Roll back the current transaction.
void setNontransactionalRead(boolean nontransactionalRead)
When the nontransactional read flag is set to false the PersistenceManager has a single TopLink UnitOfWork associated with it.
void setNontransactionalWrite(boolean arg1)
If true, allow persistent instances to be written without a transaction active.
void setOptimistic(boolean arg1)
Optimistic transactions do not hold data store locks until commit time.
void setRetainValues(boolean arg1)
If true, at commit instances retain their values and the instances transition to persistent-nontransactional.
void setSynchronization(javax.transaction.Synchronization synchronizationListener)
The user can specify a Synchronization instance to be notified on transaction completions.
void setUnitOfWork(UnitOfWork newUnitOfWork)
Set the associate unit of work.

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

begin

public void begin()
Begin a transaction. The type of transaction is determined by the setting of the Optimistic flag.
Specified by:
begin in interface javax.jdo.Transaction
Throws:
javax.jdo.JDOUserException - if transactions are managed by a container in the managed environment, or if the transaction is already active.
See Also:
setOptimistic(boolean), getOptimistic()

commit

public void commit()
Commit the current transaction.
Specified by:
commit in interface javax.jdo.Transaction
Throws:
javax.jdo.JDOUserException - if transactions are managed by a container in the managed environment, or if the transaction is not active.

getNontransactionalRead

public boolean getNontransactionalRead()
When the nontransactional read flag is set to false the PersistenceManager has a single TopLink UnitOfWork associated with it. All objects are accessed in the context of this unit of work to preserve clone identity. When the nontransactional read flag is set to true, the PersistenceManager only acquires a unit of work on the begin of the transaction and objects that are to be changed must be first reigstered into the transaction context through re-querying them, or through the getObjectById This enables read to occur on the shared object cache, without the overhead of cloning and change tracking, it also allows for nested units of work to be supported.

JDO: If true, allows persistent instances to be read without a transaction active.

Specified by:
getNontransactionalRead in interface javax.jdo.Transaction
Returns:
the value of the nontransactionalRead property

getNontransactionalWrite

public boolean getNontransactionalWrite()
If true, allows persistent instances to be written without a transaction active.
Specified by:
getNontransactionalWrite in interface javax.jdo.Transaction
Returns:
the value of the nontransactionalWrite property

getOptimistic

public boolean getOptimistic()
Optimistic transactions do not hold data store locks until commit time.
Specified by:
getOptimistic in interface javax.jdo.Transaction
Returns:
the value of the Optimistic property.

getPersistenceManager

public javax.jdo.PersistenceManager getPersistenceManager()
The Tranansaction instance is always associated with exactly one PersistenceManager.
Specified by:
getPersistenceManager in interface javax.jdo.Transaction
Returns:
the PersistenceManager for this Transaction instance

getRetainValues

public boolean getRetainValues()
If true, at commit time instances retain their field values.
Specified by:
getRetainValues in interface javax.jdo.Transaction
Returns:
the value of the retainValues property

getSynchronization

public javax.transaction.Synchronization getSynchronization()
The user-specified Synchronization instance for this Transaction instance.
Specified by:
getSynchronization in interface javax.jdo.Transaction
Returns:
the user-specified Synchronization instance.

isActive

public boolean isActive()
Returns whether there is a transaction currently active.
Specified by:
isActive in interface javax.jdo.Transaction
Returns:
true if the transaction is active.

rollback

public void rollback()
Roll back the current transaction.
Specified by:
rollback in interface javax.jdo.Transaction
Throws:
javax.jdo.JDOUserException - if transactions are managed by a container in the managed environment, or if the transaction is not active.

setNontransactionalRead

public void setNontransactionalRead(boolean nontransactionalRead)
When the nontransactional read flag is set to false the PersistenceManager has a single TopLink UnitOfWork associated with it. All objects are accessed in the context of this unit of work to preserve clone identity. When the nontransactional read flag is set to true, the current transaction is inactivated and the current UnitOfWork is released, the PersistenceManager only acquires a unit of work on the begin of the transaction and objects that are to be changed must be first reigstered into the transaction context through re-querying them, or through the getObjectById. This enables read to occur on the shared object cache, without the overhead of cloning and change tracking, it also allows for nested units of work to be supported. NOTE:

JDO: If true, allow persistent instances to be read without a transaction active. If an implementation does not support this option, a JDOUnsupportedOptionException is thrown.

Specified by:
setNontransactionalRead in interface javax.jdo.Transaction
Parameters:
nontransactionalRead - the value of the nontransactionalRead property

setNontransactionalWrite

public void setNontransactionalWrite(boolean arg1)
If true, allow persistent instances to be written without a transaction active. If an implementation does not support this option, a JDOUnsupportedOptionException is thrown.
Specified by:
setNontransactionalWrite in interface javax.jdo.Transaction

setOptimistic

public void setOptimistic(boolean arg1)
Optimistic transactions do not hold data store locks until commit time. If an implementation does not support this option, a JDOUnsupportedOptionException is thrown.
Specified by:
setOptimistic in interface javax.jdo.Transaction

setRetainValues

public void setRetainValues(boolean arg1)
If true, at commit instances retain their values and the instances transition to persistent-nontransactional. If an implementation does not support this option, a JDOUnsupportedOptionException is thrown.
Specified by:
setRetainValues in interface javax.jdo.Transaction

setSynchronization

public void setSynchronization(javax.transaction.Synchronization synchronizationListener)
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 state transitions of persistent and transactional instances, following the data store commit or rollback operation.

Only one Synchronization instance can be registered with the Transaction. If the application requires more than one instance to receive synchronization callbacks, then the single application instance is responsible for managing them, and forwarding callbacks to them.

Specified by:
setSynchronization in interface javax.jdo.Transaction

getUnitOfWork

public UnitOfWork getUnitOfWork()
Return the associated TopLink unit of work.

setUnitOfWork

public void setUnitOfWork(UnitOfWork newUnitOfWork)
Set the associate unit of work.

Copyright © 1998, 2005 Oracle Corporation. All Rights Reserved.