|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.database.TxSimple
public final class TxSimple
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 |
---|
public TxSimple(SqlId[] aSqlIds, Object[] aAllParams)
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.
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 |
---|
public int executeTx() throws DAOException
Tx
executeTx
in interface Tx
DAOException
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |