Modifier and Type | Field and Description |
---|---|
static int |
MAX_LITERALS_IN_IN_CLAUSE
The maximum number of literals that may appear in an in clause.
|
Modifier and Type | Method and Description |
---|---|
static void |
close(ResultSet resultSet,
Statement statement,
Connection connection)
Closes the supplied resultSet, statement and connection.
|
static String |
encode(String parameter)
Simple encode method that encodes a SQL parameter to prevent SQL injection.
|
static Connection |
getConnection()
Gets a database connection from the database that is configured in
GlobalSettings . |
static <T> List<T> |
getEntitiesByColumnCriteria(DataSource dataSource,
String tableNames,
String matchingColumnName,
String columnNames,
String orderByColumnNames,
Boolean descending,
ResultSetRowCallBackInterface<T> callBackInterface,
Integer maxEntities,
List<?> criteria)
Retrieves entities from a database table with the supplied name, based on a supplied collection of criteria that are to
match a supplied column of the table using an SQL in clause.
In short this method allows you to execute statements like: SELECT COL1,COL2,COL3 FROM TABLE1,TABLE2 WHERE COL4 IN (1,2,3); Normally you only want to use this method when the number of criteria (the 1,2,3 in the example above) is very large and can't be selected with an IN (SELECT ...). |
public static final int MAX_LITERALS_IN_IN_CLAUSE
public static Connection getConnection() throws SQLException
GlobalSettings
.GlobalSettings
.SQLException
- When no connection could be obtained.public static void close(ResultSet resultSet, Statement statement, Connection connection)
resultSet
- The resultSet to close or null.statement
- The statement to close or null.connection
- The connection to close or null.public static String encode(String parameter)
parameter
- The parameter to encode.public static <T> List<T> getEntitiesByColumnCriteria(DataSource dataSource, String tableNames, String matchingColumnName, String columnNames, String orderByColumnNames, Boolean descending, ResultSetRowCallBackInterface<T> callBackInterface, Integer maxEntities, List<?> criteria) throws SQLException
T
- Type of the elements in the ResultSetRowCallBackInterface.dataSource
- The datasource to execute the query.tableNames
- The names of the tables separated with a comma or a single table name.
matchingColumnName
- The name of the column to match the criteria against.columnNames
- Comma separated list of column names to retrieve.orderByColumnNames
- The names of the order by columns separated with a comma or a single column name.
descending
- True for descending, false or null for ascending.callBackInterface
- the ResultSetRowCallBackInterface to run to actually get the entities.maxEntities
- the maximum number of entities to return, or null for an unlimited number of entities.criteria
- List of criteria to match against the supplied matchingColumnNames of the entities to retrieve.
IllegalArgumentException
- When either the supplied tableNames, matchingColumnName, columnNames or criteria is
empty.NullPointerException
- When either the supplied dataSource, tableNames, matchingColumnName, columnNames,
callBackInterface or criteria is null.SQLException
- When the statement could not be executed.Copyright © 2008–2018. All rights reserved.