Class SqlTemplate<I,โR>
- java.lang.Object
-
- io.vertx.rxjava3.sqlclient.templates.SqlTemplate<I,โR>
-
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate
public class SqlTemplate<I,โR> extends Object implements io.vertx.lang.rx.RxDelegate
An SQL template.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 the
originalnon RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static io.vertx.lang.rx.TypeArg<SqlTemplate>__TYPE_ARGio.vertx.lang.rx.TypeArg<I>__typeArg_0io.vertx.lang.rx.TypeArg<R>__typeArg_1
-
Constructor Summary
Constructors Constructor Description SqlTemplateโ(SqlTemplate delegate)SqlTemplateโ(Object delegate, io.vertx.lang.rx.TypeArg<I> typeArg_0, io.vertx.lang.rx.TypeArg<R> typeArg_1)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequalsโ(Object o)Single<R>executeโ(I params)Execute the query with theparametersSingle<R>executeBatchโ(List<I> batch)Execute a batch query with thebatch.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.SqlTemplategetDelegate()inthashCode()<T> SqlTemplate<T,โR>mapFromโ(TupleMapper<T> mapper)Set a parameters user defined mapping function.<T> SqlTemplate<T,โR>mapFromโ(Class<T> type)Set a parameters user defined class mapping.<U> SqlTemplate<I,โRowSet<U>>mapToโ(RowMapper<U> mapper)Set a row user defined mapping function.<U> SqlTemplate<I,โRowSet<U>>mapToโ(Class<U> type)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 params)Execute the query with theparametersSingle<R>rxExecuteBatchโ(List<I> batch)Execute a batch query with thebatch.StringtoString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final io.vertx.lang.rx.TypeArg<SqlTemplate> __TYPE_ARG
-
__typeArg_0
public final io.vertx.lang.rx.TypeArg<I> __typeArg_0
-
__typeArg_1
public final io.vertx.lang.rx.TypeArg<R> __typeArg_1
-
-
Constructor Detail
-
SqlTemplate
public SqlTemplateโ(SqlTemplate delegate)
-
-
Method Detail
-
getDelegate
public SqlTemplate getDelegate()
- Specified by:
getDelegatein interfaceio.vertx.lang.rx.RxDelegate
-
forQuery
public static SqlTemplate<Map<String,โObject>,โRowSet<Row>> forQueryโ(SqlClient client, String template)
Create an SQL template for query purpose consuming map parameters and returning .- Parameters:
client- the wrapped SQL clienttemplate- the template query string- Returns:
- the template
-
forUpdate
public 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.- Parameters:
client- the wrapped SQL clienttemplate- the template update string- Returns:
- the template
-
mapFrom
public <T> SqlTemplate<T,โR> mapFromโ(TupleMapper<T> mapper)
Set a parameters user defined mapping function.At query execution, the
mapperis called to map the parameters object to aTuplethat configures the prepared query.- Parameters:
mapper- the mapping function- Returns:
- a new template
-
mapFrom
public <T> SqlTemplate<T,โR> mapFromโ(Class<T> type)
Set a parameters user defined class mapping.At query execution, the parameters object is is mapped to a
Mapthat configures the prepared query.This feature relies on
JsonObjectfeature. This likely requires to use Jackson databind in the project.- Parameters:
type- the mapping type- Returns:
- a new template
-
mapTo
public <U> SqlTemplate<I,โRowSet<U>> mapToโ(RowMapper<U> mapper)
Set a row user defined mapping function.When the query execution completes, the
mapperfunction is called to map the resulting rows to objects.- Parameters:
mapper- the mapping function- Returns:
- a new template
-
mapTo
public <U> SqlTemplate<I,โRowSet<U>> mapToโ(Class<U> type)
Set a row user defined mapping function.When the query execution completes, resulting rows are mapped to
typeinstances.This feature relies on
JsonObjectfeature. This likely requires to use Jackson databind in the project.- Parameters:
type- the mapping type- Returns:
- a new template
-
execute
public Single<R> executeโ(I params)
Execute the query with theparameters- Parameters:
params- the query parameters- Returns:
- a future notified with the result
-
rxExecute
public Single<R> rxExecuteโ(I params)
Execute the query with theparameters- Parameters:
params- the query parameters- Returns:
- a future notified with the result
-
executeBatch
public Single<R> executeBatchโ(List<I> batch)
Execute a batch query with thebatch.Each item in the batch is mapped to a tuple.
- Parameters:
batch- the batch- Returns:
- a future notified with the result
-
rxExecuteBatch
public Single<R> rxExecuteBatchโ(List<I> batch)
Execute a batch query with thebatch.Each item in the batch is mapped to a tuple.
- Parameters:
batch- the batch- Returns:
- a future notified with the result
-
newInstance
public static <I,โR> SqlTemplate<I,โR> newInstanceโ(SqlTemplate arg)
-
newInstance
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)
-
-