oracle.toplink.jdo
Class JDOTransaction

oracle.toplink.jdo.JDOTransaction

public class JDOTransaction

JDO wrapper for a TopLink unit of work.


Constructor Summary
 
Method Summary
TypeMethod
 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.
 oracle.toplink.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.
 

Constructor Detail
Method Detail

begin

public void begin()
Begin a transaction. The type of transaction is determined by the setting of the Optimistic flag.
Throws:
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.
Throws:
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.

Returns:
the value of the nontransactionalRead property

getNontransactionalWrite

public boolean getNontransactionalWrite()
If true, allows persistent instances to be written without a transaction active.
Returns:
the value of the nontransactionalWrite property

getOptimistic

public boolean getOptimistic()
Optimistic transactions do not hold data store locks until commit time.
Returns:
the value of the Optimistic property.

getPersistenceManager

public oracle.toplink.jdo.PersistenceManager getPersistenceManager()
The Tranansaction instance is always associated with exactly one PersistenceManager.
Returns:
the PersistenceManager for this Transaction instance

getRetainValues

public boolean getRetainValues()
If true, at commit time instances retain their field values.
Returns:
the value of the retainValues property

getSynchronization

public javax.transaction.Synchronization getSynchronization()
The user-specified Synchronization instance for this Transaction instance.
Returns:
the user-specified Synchronization instance.

isActive

public boolean isActive()
Returns whether there is a transaction currently active.
Returns:
true if the transaction is active.

rollback

public void rollback()
Roll back the current transaction.
Throws:
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.

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.
Parameters:
nontransactionalWrite - the value of the nontransactionalRead property

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.
Parameters:
optimistic - the value of the Optimistic flag.

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.
Parameters:
retainValues - the value of the retainValues property

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.

Parameters:
sync - the Synchronization instance to be notified; null for none

getUnitOfWork

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

setUnitOfWork

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