public class SqlTemplate<I,R> extends Object
SQL templates are useful for interacting with a relational database.
SQL templates execute queries using named instead of positional parameters. Query execution is parameterized
by a map of string to objects instead of a Tuple
. The default source of parameters is a
simple map, a user defined mapping can be used instead given it maps the source to such a map.
SQL template default results are , a user defined mapping can be used instead, mapping the result set to a of the mapped type.
NOTE: This class has been automatically generated from theoriginal
non RX-ified interface using Vert.x codegen.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<SqlTemplate> |
__TYPE_ARG |
io.vertx.lang.rx.TypeArg<I> |
__typeArg_0 |
io.vertx.lang.rx.TypeArg<R> |
__typeArg_1 |
Constructor and Description |
---|
SqlTemplate(Object delegate,
io.vertx.lang.rx.TypeArg<I> typeArg_0,
io.vertx.lang.rx.TypeArg<R> typeArg_1) |
SqlTemplate(SqlTemplate delegate) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Single<R> |
execute(I parameters)
Execute the query with the
parameters |
Single<R> |
executeBatch(List<I> batch)
Execute a batch query with the
batch . |
static SqlTemplate<Map<String,Object>,RowSet<Row>> |
forQuery(SqlClient client,
String template)
Create an SQL template for query purpose consuming map parameters and returning .
|
static SqlTemplate<Map<String,Object>,SqlResult<Void>> |
forUpdate(SqlClient client,
String template)
Create an SQL template for query purpose consuming map parameters and returning void.
|
SqlTemplate |
getDelegate() |
int |
hashCode() |
<T> SqlTemplate<T,R> |
mapFrom(Class<T> type)
Set a parameters user defined class mapping.
|
<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.
|
static <I,R> SqlTemplate<I,R> |
newInstance(SqlTemplate arg) |
static <I,R> SqlTemplate<I,R> |
newInstance(SqlTemplate arg,
io.vertx.lang.rx.TypeArg<I> __typeArg_I,
io.vertx.lang.rx.TypeArg<R> __typeArg_R) |
Single<R> |
rxExecute(I parameters)
Execute the query with the
parameters |
Single<R> |
rxExecuteBatch(List<I> batch)
Execute a batch query with the
batch . |
String |
toString() |
public static final io.vertx.lang.rx.TypeArg<SqlTemplate> __TYPE_ARG
public final io.vertx.lang.rx.TypeArg<I> __typeArg_0
public final io.vertx.lang.rx.TypeArg<R> __typeArg_1
public SqlTemplate(SqlTemplate delegate)
public SqlTemplate getDelegate()
public static SqlTemplate<Map<String,Object>,RowSet<Row>> forQuery(SqlClient client, String template)
client
- the wrapped SQL clienttemplate
- the template query stringpublic static SqlTemplate<Map<String,Object>,SqlResult<Void>> forUpdate(SqlClient client, String template)
client
- the wrapped SQL clienttemplate
- the template update stringpublic <T> SqlTemplate<T,R> mapFrom(TupleMapper<T> mapper)
At query execution, the mapper
is called to map the parameters object
to a Tuple
that configures the prepared query.
mapper
- the mapping functionpublic <T> SqlTemplate<T,R> mapFrom(Class<T> type)
At query execution, the parameters object is is mapped to a Map
that
configures the prepared query.
This feature relies on JsonObject
feature. This likely requires
to use Jackson databind in the project.
type
- the mapping typepublic <U> SqlTemplate<I,RowSet<U>> mapTo(RowMapper<U> mapper)
When the query execution completes, the mapper
function is called to map the resulting
rows to objects.
mapper
- the mapping functionpublic <U> SqlTemplate<I,RowSet<U>> mapTo(Class<U> type)
When the query execution completes, resulting rows are mapped to type
instances.
This feature relies on JsonObject
feature. This likely requires
to use Jackson databind in the project.
type
- the mapping typepublic Single<R> execute(I parameters)
parameters
parameters
- the query parameterspublic Single<R> rxExecute(I parameters)
parameters
parameters
- the query parameterspublic Single<R> executeBatch(List<I> batch)
batch
.
Each item in the batch is mapped to a tuple.
batch
- the batchpublic Single<R> rxExecuteBatch(List<I> batch)
batch
.
Each item in the batch is mapped to a tuple.
batch
- the batchpublic static <I,R> SqlTemplate<I,R> newInstance(SqlTemplate arg)
public static <I,R> SqlTemplate<I,R> newInstance(SqlTemplate arg, io.vertx.lang.rx.TypeArg<I> __typeArg_I, io.vertx.lang.rx.TypeArg<R> __typeArg_R)
Copyright © 2024 Eclipse. All rights reserved.