public abstract class AbstractSchemaTransaction extends Object
Management transactions may be retried in the face of SQL exceptions to work around failures caused by transient conditions, such as DB deadlocks.
Modifier and Type | Field and Description |
---|---|
protected int |
isolationLevel |
protected int |
maxRetries |
protected org.datanucleus.store.connection.ManagedConnection |
mconn |
protected RDBMSStoreManager |
rdbmsMgr |
Constructor and Description |
---|
AbstractSchemaTransaction(RDBMSStoreManager rdbmsMgr,
int isolationLevel)
Constructs a new management transaction having the given isolation level.
|
Modifier and Type | Method and Description |
---|---|
void |
execute(org.datanucleus.ClassLoaderResolver clr)
Executes the schema transaction.
|
protected Connection |
getCurrentConnection()
Returns the current connection for the schema transaction.
|
protected abstract void |
run(org.datanucleus.ClassLoaderResolver clr)
Implements the body of the transaction.
|
abstract String |
toString()
Returns a description of the management transaction.
|
protected RDBMSStoreManager rdbmsMgr
protected final int isolationLevel
protected final int maxRetries
protected org.datanucleus.store.connection.ManagedConnection mconn
public AbstractSchemaTransaction(RDBMSStoreManager rdbmsMgr, int isolationLevel)
rdbmsMgr
- RDBMSManager to useisolationLevel
- One of the isolation level constants from java.sql.Connection.public abstract String toString()
protected abstract void run(org.datanucleus.ClassLoaderResolver clr) throws SQLException
clr
- the ClassLoaderResolverSQLException
- Thrown if the transaction fails due to a database error that should allow
the entire transaction to be retried.protected Connection getCurrentConnection() throws SQLException
SQLException
- thrown when an error occurs getting the connectionpublic final void execute(org.datanucleus.ClassLoaderResolver clr)
execute(ClassLoaderResolver)
method is invoked.
If the selected isolation level is not Connection.TRANSACTION_NONE, then commit() or rollback() is
called on the connection according to whether the invocation succeeded or not. If the invocation
failed the sequence is repeated, up to a maximum of maxRetries times, configurable by
the persistence property "datanucleus.rdbms.classAdditionMaxRetries".clr
- the ClassLoaderResolverorg.datanucleus.exceptions.NucleusDataStoreException
- If a SQL exception occurred even after "maxRetries" attempts.Copyright © 2017. All rights reserved.