Package org.datanucleus.store.rdbms
Class AbstractSchemaTransaction
java.lang.Object
org.datanucleus.store.rdbms.AbstractSchemaTransaction
- Direct Known Subclasses:
DeleteTablesSchemaTransaction
,RDBMSStoreManager.ClassAdder
,ValidateTableSchemaTransaction
An abstract base class for RDBMSManager transactions that perform some schema operation on the database.
Management transactions may be retried in the face of SQL exceptions to work around failures caused by transient conditions, such as DB deadlocks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Connection
protected final int
protected final int
protected org.datanucleus.store.connection.ManagedConnection
protected final RDBMSStoreManager
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractSchemaTransaction
(RDBMSStoreManager rdbmsMgr, int isolationLevel) Constructs a new management transaction having the given isolation level. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
execute
(org.datanucleus.ClassLoaderResolver clr) Executes the schema transaction.protected Connection
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.
-
Field Details
-
rdbmsMgr
-
isolationLevel
protected final int isolationLevel -
maxRetries
protected final int maxRetries -
mconn
protected org.datanucleus.store.connection.ManagedConnection mconn -
conn
-
-
Constructor Details
-
AbstractSchemaTransaction
Constructs a new management transaction having the given isolation level.- Parameters:
rdbmsMgr
- RDBMSManager to useisolationLevel
- One of the isolation level constants from java.sql.Connection.
-
-
Method Details
-
toString
Returns a description of the management transaction. Subclasses should override this method so that transaction failures are given an appropriate exception message. -
run
Implements the body of the transaction.- Parameters:
clr
- the ClassLoaderResolver- Throws:
SQLException
- Thrown if the transaction fails due to a database error that should allow the entire transaction to be retried.
-
getCurrentConnection
Returns the current connection for the schema transaction. Creates one if needed- Returns:
- the connection
- Throws:
SQLException
- thrown when an error occurs getting the connection
-
execute
public final void execute(org.datanucleus.ClassLoaderResolver clr) Executes the schema transaction. A database connection is acquired and theexecute(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".- Parameters:
clr
- the ClassLoaderResolver- Throws:
org.datanucleus.exceptions.NucleusDataStoreException
- If a SQL exception occurred even after "maxRetries" attempts.
-