public class SqlTemplateImpl<I,R> extends Object implements SqlTemplate<I,R>
| Modifier and Type | Field and Description |
|---|---|
protected SqlClient |
client |
static Collector<Row,Void,Void> |
NULL_COLLECTOR |
protected Function<PreparedQuery<RowSet<Row>>,PreparedQuery<R>> |
queryMapper |
protected SqlTemplate |
sqlTemplate |
protected Function<I,Tuple> |
tupleMapper |
| Constructor and Description |
|---|
SqlTemplateImpl(SqlClient client,
SqlTemplate sqlTemplate,
Function<PreparedQuery<RowSet<Row>>,PreparedQuery<R>> queryMapper,
Function<I,Tuple> tupleMapper) |
| Modifier and Type | Method and Description |
|---|---|
<U> SqlTemplate<I,SqlResult<U>> |
collecting(Collector<Row,?,U> collector)
Set a collector that will process the output and produce a custom result.
|
Future<R> |
execute(I params)
Like
SqlTemplate.execute(Object, Handler) but returns a Future of the asynchronous result |
void |
execute(I parameters,
Handler<AsyncResult<R>> handler)
Execute the query with the
parameters |
Future<R> |
executeBatch(List<I> batch)
Like
SqlTemplate.executeBatch(List, Handler) but returns a Future of the asynchronous result |
void |
executeBatch(List<I> batch,
Handler<AsyncResult<R>> handler)
Execute a batch query with the
batch. |
<T> SqlTemplate<T,R> |
mapFrom(TupleMapper<T> mapper)
Set a parameters user defined mapping function.
|
<U> SqlTemplate<I,RowSet<U>> |
mapTo(Class<U> type)
Set a row user defined mapping function.
|
<U> SqlTemplate<I,RowSet<U>> |
mapTo(RowMapper<U> mapper)
Set a row user defined mapping function.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforQuery, forUpdate, mapFromprotected final SqlClient client
protected final SqlTemplate sqlTemplate
protected Function<PreparedQuery<RowSet<Row>>,PreparedQuery<R>> queryMapper
public SqlTemplateImpl(SqlClient client, SqlTemplate sqlTemplate, Function<PreparedQuery<RowSet<Row>>,PreparedQuery<R>> queryMapper, Function<I,Tuple> tupleMapper)
public <T> SqlTemplate<T,R> mapFrom(TupleMapper<T> mapper)
SqlTemplate At query execution, the mapper is called to map the parameters object
to a Tuple that configures the prepared query.
mapFrom in interface SqlTemplate<I,R>mapper - the mapping functionpublic <U> SqlTemplate<I,SqlResult<U>> collecting(Collector<Row,?,U> collector)
SqlTemplatecollecting in interface SqlTemplate<I,R>collector - the collectorpublic <U> SqlTemplate<I,RowSet<U>> mapTo(Class<U> type)
SqlTemplate When the query execution completes, resulting rows are mapped to type instances.
This feature relies on JsonObject.mapFrom(java.lang.Object) feature. This likely requires
to use Jackson databind in the project.
mapTo in interface SqlTemplate<I,R>type - the mapping typepublic <U> SqlTemplate<I,RowSet<U>> mapTo(RowMapper<U> mapper)
SqlTemplate When the query execution completes, the mapper function is called to map the resulting
rows to objects.
mapTo in interface SqlTemplate<I,R>mapper - the mapping functionpublic void execute(I parameters, Handler<AsyncResult<R>> handler)
SqlTemplateparametersexecute in interface SqlTemplate<I,R>parameters - the query parametershandler - the result handlerpublic Future<R> execute(I params)
SqlTemplateSqlTemplate.execute(Object, Handler) but returns a Future of the asynchronous resultexecute in interface SqlTemplate<I,R>public void executeBatch(List<I> batch, Handler<AsyncResult<R>> handler)
SqlTemplatebatch.
Each item in the batch is mapped to a tuple.
executeBatch in interface SqlTemplate<I,R>batch - the batchhandler - the result handlerpublic Future<R> executeBatch(List<I> batch)
SqlTemplateSqlTemplate.executeBatch(List, Handler) but returns a Future of the asynchronous resultexecuteBatch in interface SqlTemplate<I,R>Copyright © 2021. All rights reserved.