Transaction
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 initiation and completion methods have similar semantics to javax.transaction.UserTransaction
when used outside a managed environment. When used in a managed environment, transaction initiation and completion methods may only be used with bean-managed transaction semantics.
- Since:
- JDO 1.0
Public Methods
- Throws:
- JDOUserException - if transactions are managed by a container in the managed environment, or if the transaction is already active.
- See Also:
setOptimistic
getOptimistic
- Since:
- JDO 1.0
- Throws:
- JDOUserException - if transactions are managed by a container in the managed environment, or if the transaction is not active.
- Since:
- JDO 1.0
- Return:
- the value of the nontransactionalRead property
- Since:
- JDO 1.0
- Return:
- the value of the nontransactionalWrite property
- Since:
- JDO 1.0
- Return:
- the value of the Optimistic property.
- Since:
- JDO 1.0
- Return:
- the
PersistenceManager
for thisTransaction
instance
- Since:
- JDO 1.0
- Return:
- the value of the restoreValues property
- Since:
- JDO 1.0
- Return:
- the value of the retainValues property
- Since:
- JDO 1.0
- Return:
-
true
if the transaction has been marked for rollback.
- Since:
- JDO 2.0
- Return:
- the user-specified
Synchronization
instance.
- Since:
- JDO 1.0
- Return:
-
true
if the transaction is active.
- Since:
- JDO 1.0
- Throws:
- JDOUserException - if transactions are managed by a container in the managed environment, or if the transaction is not active.
- Since:
- JDO 1.0
Standard values in order of low to high are:
- read-uncommitted
- read-committed
- repeatable-read
- snapshot
- serializable
- Parameters:
level
- the transaction isolation level
- See Also:
getIsolationLevel()
Constants.TX_READ_UNCOMMITTED
Constants.TX_READ_COMMITTED
Constants.TX_REPEATABLE_READ
Constants.TX_SNAPSHOT
Constants.TX_SERIALIZABLE
- Since:
- JDO 2.2
JDOUnsupportedOptionException
is thrown. - Parameters:
nontransactionalRead
- the value of the nontransactionalRead property
- Since:
- JDO 1.0
JDOUnsupportedOptionException
is thrown. - Parameters:
nontransactionalWrite
- the value of the nontransactionalRead property
- Since:
- JDO 1.0
JDOUnsupportedOptionException
is thrown. - Parameters:
optimistic
- the value of the Optimistic flag.
- Since:
- JDO 1.0
If false
, at rollback, the values of fields of newly persistent instances are unchanged and the instances revert to transient. Additionally, dirty instances transition to hollow. If an implementation does not support this option, a JDOUnsupportedOptionException
is thrown.
- Parameters:
restoreValues
- the value of the restoreValues property
- Since:
- JDO 1.0
JDOUnsupportedOptionException
is thrown. - Parameters:
retainValues
- the value of the retainValues property
- Since:
- JDO 1.0
true
, the transaction can no longer be committed, and any attempt to commit the transaction will throw JDOFatalDataStoreException.
- Since:
- JDO 2.0
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
- theSynchronization
instance to be notified;null
for none
- Since:
- JDO 1.0