com.jpattern.orm.session.SqlPerformer Maven / Gradle / Ivy
package com.jpattern.orm.session;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import com.jpattern.orm.exception.OrmException;
import com.jpattern.orm.exception.OrmNotUniqueResultException;
/**
*
* @author Francesco Cina
*
* 02/lug/2011
*
* An executor to perform plain SQL queries
*/
public interface SqlPerformer {
/**
* Set the maximum number of rows returnd by the execution of the sql query
*/
public void setMaxRows(int maxRows);
/**
* Return the maximum number of rows specified for this sql query.
*/
public int getMaxRows();
/**
* Set the query timeout for the statements.
*/
public void setQueryTimeout(int queryTimeout);
/**
* Return the query timeout for the statements.
*/
public int getQueryTimeout();
/**
* Issue a single SQL execute, typically a DDL statement.
* @param sql static SQL to execute
*/
void execute(String sql) throws OrmException;
/**
* Execute a query given static SQL, reading the ResultSet with a
* IResultSetReader.
* @param sql SQL query to execute
* @param rse object that will extract all rows of results
* @param args arguments to bind to the query
* @return an arbitrary result object, as returned by the IResultSetExtractor
*/
T query(String sql, ResultSetReader rse, Object... args) throws OrmException;
/**
* Execute a query given static SQL, reading the ResultSet with a
* IResultSetReader.
* @param sql SQL query to execute
* @param rse object that will extract all rows of results
* @param args arguments to bind to the query
* @return an arbitrary result object, as returned by the IResultSetExtractor
*/
T query(String sql, ResultSetReader rse, Collection> args) throws OrmException;
/**
* Execute a query given static SQL and read the result as an int value (return null if no rows are returned)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
Integer queryForInt(String sql, Collection> 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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
Long queryForLong(String sql, Collection> 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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
Double queryForDouble(String sql, Collection> 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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
Float queryForFloat(String sql, Collection> 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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
String queryForString(String sql, Collection> 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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
Boolean queryForBoolean(String sql, Collection> 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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
BigDecimal queryForBigDecimal(String sql, Collection> 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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
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)
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
* @throws OrmNotUniqueResultException if more than one row is returned from the query
*/
Object[] queryForArray(String sql, Collection> args) throws OrmException, OrmNotUniqueResultException;
/**
* 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.
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @return
*/
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy