com.jenkov.mrpersister.itf.command
Interface IDaoCommandExecutor

All Known Implementing Classes:
DaoCommandExecutor

public interface IDaoCommandExecutor

The dao command executor supplies full connection and transaction management during execution of dao commands against the database. A connection will be obtained and closed automaically in the background. For the transaction methods

Author:
Jakob Jenkov - Copyright 2005 Jenkov Development

Method Summary
 java.lang.Object execute(IDaoCommand command)
          Obtains a connection from the default data source, executes this dao command and closes the connection afterwards.
 java.lang.Object execute(IDaoCommand command, java.sql.Connection connection)
          Executes this dao command using the given connection, and closes the connection afterwards.
 java.lang.Object execute(java.lang.Object configKey, IDaoCommand command)
          Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), executes this dao command and closes the connection afterwards.
 java.lang.Object execute(java.lang.Object configKey, IDaoCommand command, java.sql.Connection connection)
          Executes the dao command using the given connection and the IPersistenceConfiguration stored by the given configKey in the persistence managers config factory), and closes the connection afterwards.
 java.lang.Object executeTransaction(IDaoCommand command)
          Obtains a connection from the default data source, sets auto commit to false, executes the dao command and tries to commit the transaction.
 java.lang.Object executeTransaction(IDaoCommand command, java.sql.Connection connection)
          Sets auto commit to false on the given connection, executes the dao command and tries to commit the transaction.
 java.lang.Object executeTransaction(java.lang.Object configKey, IDaoCommand command)
          Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), sets auto commit to false, executes the dao command and tries to commit the transaction.
 java.lang.Object executeTransaction(java.lang.Object configKey, IDaoCommand command, java.sql.Connection connection)
          Obtains the persistence configuration stored by the given config key, (in the persistence managers config factory), sets auto commit to false on the given connection, executes the dao command, and tries to commit the transaction.
 

Method Detail

execute

java.lang.Object execute(IDaoCommand command)
                         throws PersistenceException
Obtains a connection from the default data source, executes this dao command and closes the connection afterwards.

Parameters:
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

execute

java.lang.Object execute(IDaoCommand command,
                         java.sql.Connection connection)
                         throws PersistenceException
Executes this dao command using the given connection, and closes the connection afterwards.

Parameters:
command - The dao command to execute
connection - The connection used by the dao command during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

execute

java.lang.Object execute(java.lang.Object configKey,
                         IDaoCommand command)
                         throws PersistenceException
Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), executes this dao command and closes the connection afterwards.

Parameters:
configKey - The key of the IPersistenceConfiguration to get the data source from.
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

execute

java.lang.Object execute(java.lang.Object configKey,
                         IDaoCommand command,
                         java.sql.Connection connection)
                         throws PersistenceException
Executes the dao command using the given connection and the IPersistenceConfiguration stored by the given configKey in the persistence managers config factory), and closes the connection afterwards.

Parameters:
configKey - The IPersistenceConfiguration used by the dao command during execution.
command - The dao command to execute
connection - The connection used by the dao command during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

java.lang.Object executeTransaction(IDaoCommand command)
                                    throws PersistenceException
Obtains a connection from the default data source, sets auto commit to false, executes the dao command and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back).

Parameters:
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

java.lang.Object executeTransaction(IDaoCommand command,
                                    java.sql.Connection connection)
                                    throws PersistenceException
Sets auto commit to false on the given connection, executes the dao command and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back). The connection will be closed after execution of the dao command.

Parameters:
command - The dao command to execute.
connection - The connection the dao command will use during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

java.lang.Object executeTransaction(java.lang.Object configKey,
                                    IDaoCommand command)
                                    throws PersistenceException
Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), sets auto commit to false, executes the dao command and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back).

Parameters:
configKey - The key of the persistence configuration the dao command is to use during execution.
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

java.lang.Object executeTransaction(java.lang.Object configKey,
                                    IDaoCommand command,
                                    java.sql.Connection connection)
                                    throws PersistenceException
Obtains the persistence configuration stored by the given config key, (in the persistence managers config factory), sets auto commit to false on the given connection, executes the dao command, and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back).

Parameters:
configKey - The key of the persistence configuration the dao command is to use during execution.
command - The dao command to execute.
connection - The connection the dao command will use during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.