O - the type of result datapublic abstract class TopiaSqlQuery<O> extends Object
prepareResult(ResultSet) to transforma result set
row to an object.
You can also do some stuff on the result set just after the query was
executed using method afterExecuteQuery(ResultSet).| Constructor and Description |
|---|
TopiaSqlQuery() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterExecuteQuery(ResultSet set)
A hook to obtain the result set just after the query execute.
|
protected String[] |
getColumnNames(ResultSet set)
Obtain the column names of a given result set using his metadata.
|
protected long |
getNbRows(ResultSet set)
From a given result set, let's count his number of row.
|
protected Map<String,Object> |
getRowAsMap(String[] columnNames,
ResultSet set)
Given the column names of the result set, transform the row of the
result set to a map with column name as key.
|
abstract PreparedStatement |
prepareQuery(Connection connection)
Prepare the statement used to do the sql query.
|
abstract O |
prepareResult(ResultSet set)
given a result set, extract the data.
|
static <T> TopiaSqlQuery<T> |
wrap(SqlFunction<Connection,PreparedStatement> preparer,
SqlFunction<ResultSet,T> transformer)
Let's you easily create a
TopiaSqlQuery using functional code-style. |
public abstract PreparedStatement prepareQuery(Connection connection) throws SQLException
connection - jdbc connection to useSQLException - if any problempublic abstract O prepareResult(ResultSet set) throws SQLException
set - the result setnullSQLException - if any probpublic void afterExecuteQuery(ResultSet set) throws SQLException
set - the result set just obtainedSQLException - if any probprotected String[] getColumnNames(ResultSet set) throws SQLException
set - the result set to inspectSQLException - if any pbprotected long getNbRows(ResultSet set) throws SQLException
set - the result set to inspectSQLException - if any pbprotected Map<String,Object> getRowAsMap(String[] columnNames, ResultSet set) throws SQLException
columnNames - column names of the result setset - the set to inspectSQLException - if any pbpublic static <T> TopiaSqlQuery<T> wrap(SqlFunction<Connection,PreparedStatement> preparer, SqlFunction<ResultSet,T> transformer)
TopiaSqlQuery using functional code-style.T - the expected return typepreparer - used to create the PreparedStatement. See prepareQuery(Connection).transformer - used to transform the ResultSet to the expected format. See prepareResult(ResultSet).prepareQuery(Connection),
prepareResult(ResultSet)Copyright © 2004–2020 Code Lutin. All rights reserved.