Package org.eclnt.ccee.db
Class DBAction
java.lang.Object
org.eclnt.ccee.db.DBAction
- All Implemented Interfaces:
ICCEEConstants
- Direct Known Subclasses:
DBIsolatedAction
Environment for executing (transactional) operations against database.
The typical way of calling is:
DBActions can be nested - i.e. within one DBAction.run()-processing you can invoke any other DBAction.run()-processing. All the code will be executed using the same connection to the database and being embedded in one transaction to the database.
The typical way of calling is:
new DBAction()
{
protected void run() throws Exception
{
...your code...
}
};
By placing your code into the run method it is automatically embedded into
corresponding database context management.DBActions can be nested - i.e. within one DBAction.run()-processing you can invoke any other DBAction.run()-processing. All the code will be executed using the same connection to the database and being embedded in one transaction to the database.
-
Field Summary
Fields inherited from interface org.eclnt.ccee.ICCEEConstants
AND, ASC, AVG, BETWEEN, BRC, BRO, COUNT, DEFAULT_CONTEXT, DESC, FUNCTIONRESULT, GREATER, GREATEREQUAL, IN, IS, ISNOT, LIKE, LL_DBG, LL_ERR, LL_INF, LL_WAR, LOWER, LOWEREQUAL, MAX, MIN, NULL, OR, ORDERBY, QPFUNCTION_LOWER, QPFUNCTION_UPPER, SUM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidAllows to add an action that is executed as part of the commit processing.final PreparedStatementcreateBatchStatement(String query) Creates a prepared statement for the query.final PreparedStatementcreateStatement(String query) Creates a PreparedStatement - this method can be called within therun()implementation in order to create a prepared statement.final PreparedStatementcreateStatement(String query, int autoGeneratedKeys) Same ascreateStatement(String)but now with additional int-indicator that is passed into the original prepareStatement(...) method.final ConnectionThe database connection that is used within the processing of methodrun().voidThis method does... ...nothing!protected final voidprotected abstract voidrun()Implementation of database operation.final StringwithSchema(String tableName) In case of using an explicit schema then this method returns the table name with some schema prefix.final StringwithSchema(DOFWEntity entity) In case of using an explicit schema then this method returns the table name with some schema prefix.
-
Constructor Details
-
DBAction
public DBAction()Opens up a DBAction within the standard context. -
DBAction
Opens up a DBAction with a special context associated.
-
-
Method Details
-
noWarning
public void noWarning()This method does... ...nothing! The only purpose is to suppress warnings that may be reported by your Java compiler - dependent on your compiler configuration.
The following code may be marked with "The allocated object is never used":new DBAction() { protected void run() throws ExceptionBy appending "noWarning()" the compiler will not mark this code, because now it is used by the "noWarning()" method:
{ ... } };
new DBAction() { protected void run() throws Exception
{ ... } }.noWarning(); -
process
-
run
Implementation of database operation. This is the method you need to override.- Throws:
Exception
-
addCommitRunnable
Allows to add an action that is executed as part of the commit processing. The execution is only performed on successful termination of the DB-transaction.
Example: you may write some logging information into some file system. Or you might send some notification messages to other systems.
Pay attention: there is no transactional context that guarantees your operations to be executed! -
withSchema
In case of using an explicit schema then this method returns the table name with some schema prefix. You may use this method if implementinng the SQL statement on your own.- Parameters:
Name- of table
-
withSchema
In case of using an explicit schema then this method returns the table name with some schema prefix. You may use this method if implementing the SQL statement on your own. -
createStatement
Creates a PreparedStatement - this method can be called within therun()implementation in order to create a prepared statement. The statemnt is automatically closed at the end of the DBAction-processing.- Parameters:
query- SQL query that is passed into the PreparedStatement.- Returns:
-
getConnection
-
createStatement
Same ascreateStatement(String)but now with additional int-indicator that is passed into the original prepareStatement(...) method. -
createBatchStatement
Creates a prepared statement for the query. If the same query is requested again then the already created statement is returned.
-