public class TransactionImpl extends Object implements Transaction
Transaction.
This is not thread-safe.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
rollbackOnly
Whether the transaction is only for roll-back.
|
protected Boolean |
serializeRead
Whether to serialise (lock) any read objects in this transaction.
|
TRANSACTION_ISOLATION_OPTION| Constructor and Description |
|---|
TransactionImpl(ExecutionContext ec,
PropertyStore properties)
Constructor for a transaction for the specified ExecutionContext.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTransactionEventListener(TransactionEventListener listener)
Adds a transaction listener.
|
void |
begin()
Method to begin the transaction.
|
void |
bindTransactionEventListener(TransactionEventListener listener)
Listeners that are never cleared, and invoked for all transactions
|
void |
close()
Method to inform the transaction that it is closed.
|
void |
commit()
Method to commit the transaction.
|
void |
end()
Method to allow the transaction to flush any resources.
|
void |
flush()
Method to flush the transaction.
|
long |
getBeginTime()
Accessor for the time (millisecs) from System.currentTimeMillis when the transaction started.
|
boolean |
getIsActive()
Similar to "isActive" except that it just returns the "active" flag whereas the isActive() method can also embody rejoining to underlying transactions.
|
boolean |
getNontransactionalRead()
Accessor for the nontransactionalRead flag for this transaction.
|
boolean |
getNontransactionalWrite()
Accessor for the nontransactionalWrite flag for this transaction.
|
boolean |
getNontransactionalWriteAutoCommit()
Accessor for whether non-tx writes are auto-commit.
|
boolean |
getOptimistic()
Accessor for the Optimistic setting
|
Map<String,Object> |
getOptions()
Obtain all settings for this Transaction
|
boolean |
getRestoreValues()
Accessor for the restoreValues flag for this transaction.
|
boolean |
getRetainValues()
Accessor for the retainValues flag for this transaction.
|
boolean |
getRollbackOnly()
Accessor for the "rollback only" flag.
|
Boolean |
getSerializeRead()
Accessor for the setting for whether to serialize read objects (lock them).
|
Synchronization |
getSynchronization()
Accessor for the synchronization object to be notified on transaction completion.
|
protected void |
internalBegin()
Method to begin the transaction.
|
protected void |
internalCommit()
Internal commit, DataNucleus invokes it's own transaction manager implementation, if
an external transaction manager is not used.
|
protected void |
internalPostCommit()
Method to perform any post-commit operations like calling the users "afterCompletion"
and general clean up after the commit.
|
protected void |
internalPreCommit()
Method to perform any pre-commit operations like flushing to the datastore, calling the users
"beforeCompletion", and general preparation for the commit.
|
protected void |
internalPreRollback() |
protected void |
internalRollback()
Internal rollback.
|
boolean |
isActive()
Accessor for whether the transaction is active.
|
boolean |
isCommitting()
Accessor for whether the transaction is comitting.
|
void |
preFlush()
Method to notify of preFlush.
|
void |
releaseSavepoint(String name)
Method to deregister the current position as a savepoint with the provided name (assuming the datastore supports it).
|
void |
removeTransactionEventListener(TransactionEventListener listener)
Removes the specified listener.
|
void |
rollback()
Method to rollback the transaction.
|
void |
rollbackToSavepoint(String name)
Method to rollback the transaction to the specified savepoint (assuming the datastore supports it).
|
void |
setNontransactionalRead(boolean nontransactionalRead)
Mutator for the setting of nontransactional read.
|
void |
setNontransactionalWrite(boolean nontransactionalWrite)
Mutator for the setting of nontransactional write.
|
void |
setNontransactionalWriteAutoCommit(boolean autoCommit)
Mutator for whether non-tx writes are auto-commit (false implies delayed til next transaction commit).
|
void |
setOptimistic(boolean optimistic)
Mutator for the optimistic transaction setting.
|
void |
setOption(String option,
boolean value) |
void |
setOption(String option,
int value) |
void |
setOption(String option,
Object value) |
void |
setOption(String option,
String value) |
void |
setProperties(PropertyStore properties) |
void |
setRestoreValues(boolean restoreValues)
Mutator for the setting of restore values.
|
void |
setRetainValues(boolean retainValues)
Mutator for the setting of retain values.
|
void |
setRollbackOnly()
Mutator for the "rollback only" flag.
|
void |
setSavepoint(String name)
Method to register the current position as a savepoint with the provided name (assuming the datastore supports it).
|
void |
setSerializeRead(Boolean serializeRead)
Mutator for whether to serialize (lock) any read objects in this transaction.
|
void |
setSynchronization(Synchronization sync)
Mutator for the synchronization object to be notified on transaction completion.
|
protected boolean rollbackOnly
protected Boolean serializeRead
public TransactionImpl(ExecutionContext ec, PropertyStore properties)
ec - ExecutionContextproperties - Properties to use with the transactionpublic long getBeginTime()
TransactiongetBeginTime in interface Transactionpublic void close()
Transactionclose in interface Transactionpublic void begin()
begin in interface Transactionprotected void internalBegin()
public void preFlush()
preFlush in interface Transactionpublic void flush()
flush in interface Transactionpublic void end()
end in interface Transactionpublic void commit()
commit in interface Transactionprotected void internalPreCommit()
protected void internalCommit()
public void rollback()
rollback in interface Transactionprotected void internalPreRollback()
protected void internalRollback()
protected void internalPostCommit()
public boolean isActive()
isActive in interface Transactionpublic boolean getIsActive()
getIsActive in interface Transactionpublic boolean isCommitting()
isCommitting in interface Transactionpublic boolean getNontransactionalRead()
getNontransactionalRead in interface Transactionpublic boolean getNontransactionalWrite()
getNontransactionalWrite in interface Transactionpublic boolean getNontransactionalWriteAutoCommit()
getNontransactionalWriteAutoCommit in interface Transactionpublic boolean getOptimistic()
getOptimistic in interface Transactionpublic boolean getRestoreValues()
getRestoreValues in interface Transactionpublic boolean getRetainValues()
getRetainValues in interface Transactionpublic boolean getRollbackOnly()
getRollbackOnly in interface Transactionpublic Synchronization getSynchronization()
getSynchronization in interface Transactionpublic void setNontransactionalRead(boolean nontransactionalRead)
setNontransactionalRead in interface TransactionnontransactionalRead - Whether to allow nontransactional read operationspublic void setNontransactionalWrite(boolean nontransactionalWrite)
setNontransactionalWrite in interface TransactionnontransactionalWrite - Whether to allow nontransactional write operationspublic void setNontransactionalWriteAutoCommit(boolean autoCommit)
setNontransactionalWriteAutoCommit in interface TransactionautoCommit - Whether auto-commit of non-tx writespublic void setOptimistic(boolean optimistic)
setOptimistic in interface Transactionoptimistic - The optimistic transaction setting.public void setRestoreValues(boolean restoreValues)
setRestoreValues in interface TransactionrestoreValues - Whether to restore values at commitpublic void setRetainValues(boolean retainValues)
setRetainValues in interface TransactionretainValues - Whether to retain values at commitpublic void setRollbackOnly()
setRollbackOnly in interface Transactionpublic void setSavepoint(String name)
TransactionsetSavepoint in interface Transactionname - Savepoint namepublic void releaseSavepoint(String name)
TransactionreleaseSavepoint in interface Transactionname - Savepoint namepublic void rollbackToSavepoint(String name)
TransactionrollbackToSavepoint in interface Transactionname - Savepoint namepublic void setSynchronization(Synchronization sync)
setSynchronization in interface Transactionsync - The synchronization object to be notified on transaction completionpublic void addTransactionEventListener(TransactionEventListener listener)
TransactionaddTransactionEventListener in interface Transactionlistener - The listener to addpublic void removeTransactionEventListener(TransactionEventListener listener)
TransactionremoveTransactionEventListener in interface Transactionlistener - Listener to removepublic void bindTransactionEventListener(TransactionEventListener listener)
TransactionbindTransactionEventListener in interface Transactionlistener - listener to bindpublic Boolean getSerializeRead()
TransactiongetSerializeRead in interface Transactionpublic void setSerializeRead(Boolean serializeRead)
TransactionsetSerializeRead in interface TransactionserializeRead - Whether to serialise (lock) any read objectspublic Map<String,Object> getOptions()
TransactiongetOptions in interface Transactionpublic void setOption(String option, int value)
setOption in interface Transactionpublic void setOption(String option, boolean value)
setOption in interface Transactionpublic void setOption(String option, String value)
setOption in interface Transactionpublic void setOption(String option, Object value)
setOption in interface Transactionpublic void setProperties(PropertyStore properties)
Copyright © 2019. All rights reserved.