com.googlecode.jpattern.orm.session
Interface ISqlPerformer

All Known Implementing Classes:
ASqlPerformer, DataSourceSqlPerformer, JdbcTemplateSqlPerformer, NullSqlExecutor

public interface ISqlPerformer

Author:
Francesco Cina 02/lug/2011 An executor to perform plain SQL queries

Method Summary
 int[] batchUpdate(List<String> sqls)
          Issue multiple SQL updates on a single JDBC Statement using batching.
 int[] batchUpdate(String sql, IPreparedStatementCreator psc)
          Issue multiple SQL updates on a single JDBC Statement using batching.
 int[] batchUpdate(String sql, List<Object[]> args)
          Issue multiple SQL updates on a single JDBC Statement using batching.
 void execute(String sql)
          Issue a single SQL execute, typically a DDL statement.
 int getMaxRows()
          Return the maximum number of rows specified for this sql query.
 int getQueryTimeout()
          Return the query timeout for the statements.
<T> T
query(String sql, IResultSetReader<T> rse, Object... args)
          Execute a query given static SQL, reading the ResultSet with a IResultSetReader.
 Object[] queryForArray(String sql, Object... args)
          Execute a query given static SQL and read the result creating an ordered array with the extracted column values (return null if no rows are returned)
 BigDecimal queryForBigDecimal(String sql, Object... args)
          Execute a query given static SQL and read the result as a BigDecimal value (return null if no rows are returned)
 Boolean queryForBoolean(String sql, Object... args)
          Execute a query given static SQL and read the result as a boolean value (return null if no rows are returned)
 Double queryForDouble(String sql, Object... args)
          Execute a query given static SQL and read the result as a double value (return null if no rows are returned)
 Float queryForFloat(String sql, Object... args)
          Execute a query given static SQL and read the result as a float value (return null if no rows are returned)
 Integer queryForInt(String sql, Object... args)
          Execute a query given static SQL and read the result as an int value (return null if no rows are returned)
 List<Object[]> queryForList(String sql, Object... args)
          Execute a query given static SQL and read the result creating a List of all the ordered arrays with the extracted column values for every row.
 Long queryForLong(String sql, Object... args)
          Execute a query given static SQL and read the result as an long value (return null if no rows are returned)
 String queryForString(String sql, Object... args)
          Execute a query given static SQL and read the result as a String value (return null if no rows are returned)
 void setMaxRows(int maxRows)
          Set the maximum number of rows returnd by the execution of the sql query
 void setQueryTimeout(int queryTimeout)
          Set the query timeout for the statements.
 int update(String sql, IGeneratedKeyReader generatedKeyReader, Object... args)
          Issue an update statement using a PreparedStatementCreator to provide SQL and any required parameters.
 int update(String sql, Object... args)
          Perform a single SQL update operation (such as an insert, update or delete statement).
 

Method Detail

setMaxRows

void setMaxRows(int maxRows)
Set the maximum number of rows returnd by the execution of the sql query


getMaxRows

int getMaxRows()
Return the maximum number of rows specified for this sql query.


setQueryTimeout

void setQueryTimeout(int queryTimeout)
Set the query timeout for the statements.


getQueryTimeout

int getQueryTimeout()
Return the query timeout for the statements.


execute

void execute(String sql)
             throws OrmException
Issue a single SQL execute, typically a DDL statement.

Parameters:
sql - static SQL to execute
Throws:
OrmException

query

<T> T query(String sql,
            IResultSetReader<T> rse,
            Object... args)
        throws OrmException
Execute a query given static SQL, reading the ResultSet with a IResultSetReader.

Parameters:
sql - SQL query to execute
rse - object that will extract all rows of results
args - arguments to bind to the query
Returns:
an arbitrary result object, as returned by the IResultSetExtractor
Throws:
OrmException

queryForInt

Integer queryForInt(String sql,
                    Object... args)
                    throws OrmException,
                           OrmNotUniqueResultException
Execute a query given static SQL and read the result as an int value (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForLong

Long queryForLong(String sql,
                  Object... args)
                  throws OrmException,
                         OrmNotUniqueResultException
Execute a query given static SQL and read the result as an long value (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForDouble

Double queryForDouble(String sql,
                      Object... args)
                      throws OrmException,
                             OrmNotUniqueResultException
Execute a query given static SQL and read the result as a double value (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForFloat

Float queryForFloat(String sql,
                    Object... args)
                    throws OrmException,
                           OrmNotUniqueResultException
Execute a query given static SQL and read the result as a float value (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForString

String queryForString(String sql,
                      Object... args)
                      throws OrmException,
                             OrmNotUniqueResultException
Execute a query given static SQL and read the result as a String value (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForBoolean

Boolean queryForBoolean(String sql,
                        Object... args)
                        throws OrmException,
                               OrmNotUniqueResultException
Execute a query given static SQL and read the result as a boolean value (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForBigDecimal

BigDecimal queryForBigDecimal(String sql,
                              Object... args)
                              throws OrmException,
                                     OrmNotUniqueResultException
Execute a query given static SQL and read the result as a BigDecimal value (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForArray

Object[] queryForArray(String sql,
                       Object... args)
                       throws OrmException,
                              OrmNotUniqueResultException
Execute a query given static SQL and read the result creating an ordered array with the extracted column values (return null if no rows are returned)

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmNotUniqueResultException - if more than one row is returned from the query
OrmException

queryForList

List<Object[]> queryForList(String sql,
                            Object... args)
                            throws OrmException
Execute a query given static SQL and read the result creating a List of all the ordered arrays with the extracted column values for every row.

Parameters:
sql - SQL query to execute
args - arguments to bind to the query
Returns:
Throws:
OrmException

update

int update(String sql,
           Object... args)
           throws OrmException
Perform a single SQL update operation (such as an insert, update or delete statement).

Parameters:
sql - static SQL to execute
args - arguments to bind to the query
Returns:
the number of rows affected
Throws:
OrmException

update

int update(String sql,
           IGeneratedKeyReader generatedKeyReader,
           Object... args)
           throws OrmException
Issue an update statement using a PreparedStatementCreator to provide SQL and any required parameters. Generated keys can be read using the IGeneratedKeyReader.

Parameters:
psc - object that provides SQL and any necessary parameters
generatedKeyReader - IGeneratedKeyReader to read the generated key
Returns:
the number of rows affected
Throws:
OrmException

batchUpdate

int[] batchUpdate(List<String> sqls)
                  throws OrmException
Issue multiple SQL updates on a single JDBC Statement using batching.

Parameters:
sql - defining a List of SQL statements that will be executed.
Returns:
an array of the number of rows affected by each statement
Throws:
OrmException

batchUpdate

int[] batchUpdate(String sql,
                  List<Object[]> args)
                  throws OrmException
Issue multiple SQL updates on a single JDBC Statement using batching. The same query is executed for every Object array present in the args list which is the list of arguments to bind to the query.

Parameters:
sql - defining a List of SQL statements that will be executed.
args - defining a List of Object arrays to bind to the query.
Returns:
an array of the number of rows affected by each statement
Throws:
OrmException

batchUpdate

int[] batchUpdate(String sql,
                  IPreparedStatementCreator psc)
                  throws OrmException
Issue multiple SQL updates on a single JDBC Statement using batching. The values on the generated PreparedStatement are set using an IPreparedStatementCreator.

Parameters:
sql - defining a List of SQL statements that will be executed.
psc - the creator to bind values on the PreparedStatement
Returns:
an array of the number of rows affected by each statement
Throws:
OrmException


Copyright © 2011. All Rights Reserved.