public abstract class AbstractQuery extends Object
| Constructor and Description |
|---|
AbstractQuery() |
| Modifier and Type | Method and Description |
|---|---|
abstract List<Object> |
getParams() |
abstract String |
getSQL() |
PreparedStatement |
prepareStatement(@NonNull Connection con)
Creates a prepared statement and sets parameter values.
|
PreparedStatement |
prepareStatement(@NonNull Connection con,
int autoGeneratedKeys)
Creates a prepared statement and sets parameter values.
|
ResultSetWrapper |
query(@NonNull Connection con)
Creates a prepared statement and executes a query.
|
<T> Optional<T> |
queryAndMap(@NonNull DataSource source,
@NonNull ResultSetMapper<T> mapper)
Obtains a connection from the source, performs a query, calls
ResultSetWrapper.map(ResultSetMapper) with the specified
mapper and returns the result. |
<T> List<T> |
queryAndMapAll(@NonNull DataSource source,
@NonNull ResultSetMapper<T> mapper)
Obtains a connection from the source, performs a query, calls
ResultSetWrapper.mapAll(ResultSetMapper) with the specified
mapper and returns the result. |
int |
update(@NonNull Connection con)
Creates a prepared statement and executes an update.
|
int |
update(@NonNull DataSource source)
Creates a prepared statement and executes an update.
|
ResultSetWrapper |
updateWithKeys(@NonNull Connection con)
Executes an update, returning generated keys.
|
<T> Optional<T> |
updateWithKeysAndMap(@NonNull DataSource source,
@NonNull ResultSetMapper<T> mapper)
Obtains a connection from the source, executes an update, returns generated keys mapped using specified mapper.
|
<T> List<T> |
updateWithKeysAndMapAll(@NonNull DataSource source,
@NonNull ResultSetMapper<T> mapper)
Obtains a connection from the source, executes an update, returns generated keys mapped using specified mapper.
|
public abstract String getSQL()
public abstract List<Object> getParams()
? in the SQL query).public PreparedStatement prepareStatement(@NonNull @NonNull Connection con) throws SQLException
con - Connection to the database.SQLException - On SQL error.public PreparedStatement prepareStatement(@NonNull @NonNull Connection con, int autoGeneratedKeys) throws SQLException
con - Connection to the database.autoGeneratedKeys - A value to be passed to autoGeneratedKeys parameter of prepareStatement.SQLException - On SQL error.public int update(@NonNull
@NonNull Connection con)
throws SQLException
con - Connection to the database.executeUpdate.SQLException - On SQL error.public int update(@NonNull
@NonNull DataSource source)
throws SQLException
source - Source of connections.executeUpdate.SQLException - On SQL error.public ResultSetWrapper updateWithKeys(@NonNull @NonNull Connection con) throws SQLException
con - Connection to the database.SQLException - On SQL error.public <T> Optional<T> updateWithKeysAndMap(@NonNull @NonNull DataSource source, @NonNull @NonNull ResultSetMapper<T> mapper) throws SQLException
T - Type of the result.source - Source of connections.mapper - Mapper.SQLException - On SQL error.public <T> List<T> updateWithKeysAndMapAll(@NonNull @NonNull DataSource source, @NonNull @NonNull ResultSetMapper<T> mapper) throws SQLException
T - Type of list elements.source - Source of connections.mapper - Mapper.SQLException - On SQL error.public ResultSetWrapper query(@NonNull @NonNull Connection con) throws SQLException
con - Connection to database.SQLException - On SQL error.public <T> Optional<T> queryAndMap(@NonNull @NonNull DataSource source, @NonNull @NonNull ResultSetMapper<T> mapper) throws SQLException
ResultSetWrapper.map(ResultSetMapper) with the specified
mapper and returns the result.T - Result type.source - Source of connections.mapper - Mapper.SQLException - On SQL error.public <T> List<T> queryAndMapAll(@NonNull @NonNull DataSource source, @NonNull @NonNull ResultSetMapper<T> mapper) throws SQLException
ResultSetWrapper.mapAll(ResultSetMapper) with the specified
mapper and returns the result.T - Result type.source - Source of connections.mapper - Mapper.SQLException - On SQL error.Copyright © 2021. All rights reserved.