Version 4.10.0

hirondelle.web4j.database
Class TxSimple

Object
  extended by hirondelle.web4j.database.TxSimple
All Implemented Interfaces:
Tx

public final class TxSimple
extends Object
implements Tx

Perform the simplest kinds of transactions.

Executes a number of SQL statements, in the same order as passed to the constructor. Each SQL statement is executed once and only once, without any iteration. Each SQL statement must perform an INSERT, DELETE, or UPDATE operation. No SELECTs are allowed.

It is likely that a significant fraction (perhaps as high as 50%) of all transactions can be implemented with this class.

Example use case:

 SqlId[] sqlIds = {ADD_THIS, DELETE_THAT};
 Object[] params = {blah.getX(), blah.getY(), blah.getZ(), blah.getQ()}; 
 Tx doStuff = new TxSimple(sqlIds, params);
 int numRecordsAffected = doStuff.executeTx();
 

In this example, blah will usually represent a Model Object. The data in params is divided up among the various sqlIds. (This division is performed internally by this class.)

This class uses strong ordering conventions. The order of items in each array passed to the constructor is very important (see TxSimple(SqlId[], Object[])).


Constructor Summary
TxSimple(SqlId[] aSqlIds, Object[] aAllParams)
          Constructor.
 
Method Summary
 int executeTx()
          Execute a database transaction, and return the number of edited records.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TxSimple

public TxSimple(SqlId[] aSqlIds,
                Object[] aAllParams)
Constructor.

aAllParams includes the parameters for all operations, concatenated in a single array. Has at least one member.

In general, successive pieces of aAllParams are used to populate each corresponding statement, in their order of execution. The order of items is here doubly important: the first N parameters are used against the first SQL statement, the next M parameters are used against the second SQL statement, and so on. (This breakdown is deduced internally.)

And as usual, within each subset of aAllParams corresponding to an SQL statement, the order of parameters matches the order of '?' placeholders appearing in the underlying SQL statement.

Parameters:
aSqlIds - identifiers for the operations to be performed, in the order of their intended execution. Has at least one member. All of the operations are against the same database.
aAllParams - the parameters for all operations, concatenated in a single array. Has at least one member. (See above for important requirements on their order.)
Method Detail

executeTx

public int executeTx()
              throws DAOException
Description copied from interface: Tx
Execute a database transaction, and return the number of edited records.

Specified by:
executeTx in interface Tx
Throws:
DAOException

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.