|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The JDO Transaction interface provides for initiation and completion
of transactions under user control.
It is a sub-interface of the PersistenceManager
that deals with options and transaction demarcation.
Transaction options include whether optimistic concurrency control should be used for the current transaction, whether instances may hold values in the cache outside transactions, and whether values should be retained in the cache after transaction completion. These options are valid for both managed and non-managed transactions.
Transaction completion methods have the same semantics as javax.transaction UserTransaction, and are valid only in the non-managed, non-distributed transaction environment.
For operation in the distributed environment, Transaction is declared to implement javax.transaction.Synchronization. This allows for flushing the cache to the data store during externally managed transaction completion.
Method Summary | |
void |
begin()
Begin a transaction. |
void |
commit()
Commit the current transaction. |
boolean |
getNontransactionalRead()
If true, allows persistent instances to be read without a transaction active. |
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. |
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. |
boolean |
isActive()
Returns whether there is a transaction currently active. |
void |
rollback()
Roll back the current transaction. |
void |
setNontransactionalRead(boolean nontransactionalRead)
If true, allow persistent instances to be read without a transaction active. |
void |
setNontransactionalWrite(boolean nontransactionalWrite)
If true, allow persistent instances to be written without a transaction active. |
void |
setOptimistic(boolean optimistic)
Optimistic transactions do not hold data store locks until commit time. |
void |
setRetainValues(boolean retainValues)
If true, at commit instances retain their values and the instances transition to persistent-nontransactional. |
void |
setSynchronization(javax.transaction.Synchronization sync)
The user can specify a Synchronization instance to be notified on transaction completions. |
Method Detail |
public void begin()
JDOUserException
- if transactions are managed by a container
in the managed environment, or if the transaction is already active.setOptimistic(boolean)
,
getOptimistic()
public void commit()
JDOUserException
- if transactions are managed by a container
in the managed environment, or if the transaction is not active.public void rollback()
JDOUserException
- if transactions are managed by a container
in the managed environment, or if the transaction is not active.public boolean isActive()
public void setNontransactionalRead(boolean nontransactionalRead)
nontransactionalRead
- the value of the nontransactionalRead propertypublic boolean getNontransactionalRead()
public void setNontransactionalWrite(boolean nontransactionalWrite)
nontransactionalWrite
- the value of the nontransactionalRead propertypublic boolean getNontransactionalWrite()
public void setRetainValues(boolean retainValues)
retainValues
- the value of the retainValues propertypublic boolean getRetainValues()
public void setOptimistic(boolean optimistic)
optimistic
- the value of the Optimistic flag.public boolean getOptimistic()
public void setSynchronization(javax.transaction.Synchronization sync)
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.
sync
- the Synchronization instance to be notified; null for nonepublic javax.transaction.Synchronization getSynchronization()
public PersistenceManager getPersistenceManager()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |