All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gu.sql2java.SqlRunner Maven / Gradle / Ivy

There is a newer version: 5.2.0
Show newest version
package gu.sql2java;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

import gu.sql2java.exception.RuntimeDaoException;

public interface SqlRunner {

	/**
	 * Load all the elements using a SQL statement specifying a list of fields to be retrieved.
	 * @param targetTypes map of target type for column name or null
	 * @param sql the SQL statement for retrieving
	 * @param argList the arguments to use fill given prepared statement,may be null
	 * @since 3.18.3
	 */
	List runSqlAsList(Map> targetTypes, String sql, Object... argList);

	/**
	 * Load all the elements using a SQL statement specifying a list of fields to be retrieved.
	 * @param sql the SQL statement for retrieving
	 * @param argList the arguments to use fill given prepared statement,may be null
	 * @return an list of BaseBean bean, or empty list if no row return
	 * @throws RuntimeDaoException 
	 */
	List runSqlAsList(String sql, Object... argList) throws RuntimeDaoException;

	/**
	 * Load all the elements using a SQL statement specifying a list of fields to be retrieved.
	 * @param targetTypes map of target type for column name or null
	 * @param sql the SQL statement for retrieving
	 * @param argList the arguments to use fill given prepared statement,may be null
	 * @return an list of row values map, or empty list if no row return
	 * @throws RuntimeDaoException 
	 */
	List> runSqlForMap(Map> targetTypes, String sql, Object... argList)
			throws RuntimeDaoException;

	/**
	 * Load all the elements using a SQL statement specifying a fields to be retrieved.
	 * @param targetType target type for column  or null
	 * @param sql the SQL statement for retrieving
	 * @param argList the arguments to use fill given prepared statement,may be null
	 * @return an list of row values , or empty list if no row return
	 * @throws RuntimeDaoException 
	 */
	 List runSqlAsList(Class targetType, String sql, Object... argList) throws RuntimeDaoException;

	/**
	 * Load all the elements using a SQL statement specifying a row of a field to be retrieved.
	 * @param targetType target type for column or null
	 * @param sql the SQL statement for retrieving
	 * @param argList the arguments to use fill given prepared statement,may be null
	 * @return SQL statement return value
	 * @throws RuntimeDaoException
	 */
	 T runSqlForValue(Class targetType, String sql, Object... argList) throws RuntimeDaoException;

	/**
	 * Run {@code Callable} as a transaction.
* all exceptions but {@code SQLException} threw by {@code Callable} is wrapped into {@code RuntimeException}
* throw {@code NullPointerException} if {@code fun} be {@code null}
* @param type of return result * @param fun * @return return T object * @throws RuntimeDaoException */ T runAsTransaction(Callable fun) throws RuntimeDaoException; /** * Run {@code Runnable} as a transaction.no return * @param fun * @see #runAsTransaction(Runnable) * @throws RuntimeDaoException */ void runAsTransaction(Runnable fun) throws RuntimeDaoException; /** * run a SQL statement as {@link java.sql.PreparedStatement} * @param sql the SQL statement for running * @param argList the arguments to use fill given prepared statement,may be null * @return see {@link java.sql.Statement#execute(String)} */ boolean runSql(String sql, Object[] argList); /** * run a SQL statement as {@link java.sql.Statement}. * which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, * such as an SQL DDL statement. * * @param sql the SQL statement for running * @return see {@link java.sql.Statement#executeUpdate(String sql)} */ int runSql(String sql); /** * run a {@code Callable} in Disable PageHelper environment * @param type of return result * @param fun * @return return T object * @throws RuntimeDaoException * @since 3.11.1 */ public T runWithNoPage(Callable fun) throws RuntimeDaoException; /** * run a {@code Runnable} in Disable PageHelper environment * @param fun * @throws RuntimeDaoException * @since 3.11.1 */ void runWithNoPage(Runnable fun) throws RuntimeDaoException; /** * compute row count of SQL statement * @param sql * @throws RuntimeDaoException * @since 3.15.4 */ long rowCountOf(String sql) throws RuntimeDaoException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy