Class SqlTemplate<I,R>
- java.lang.Object
-
- io.vertx.mutiny.sqlclient.templates.SqlTemplate<I,R>
-
public class SqlTemplate<I,R> extends Object
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 theoriginalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<SqlTemplate>__TYPE_ARGTypeArg<I>__typeArg_0TypeArg<R>__typeArg_1
-
Constructor Summary
Constructors Constructor Description SqlTemplate(io.vertx.sqlclient.templates.SqlTemplate delegate)SqlTemplate(io.vertx.sqlclient.templates.SqlTemplate delegate, TypeArg<I> typeArg_0, TypeArg<R> typeArg_1)SqlTemplate(Object delegate, TypeArg<I> typeArg_0, TypeArg<R> typeArg_1)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)io.smallrye.mutiny.Uni<R>execute(I parameters)Execute the query with theparametersRexecuteAndAwait(I parameters)Blocking variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#execute(I).voidexecuteAndForget(I parameters)Variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#execute(I)that ignores the result of the operation.io.smallrye.mutiny.Uni<R>executeBatch(List<I> batch)Execute a batch query with thebatch.RexecuteBatchAndAwait(List<I> batch)Blocking variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#executeBatch(List).voidexecuteBatchAndForget(List<I> batch)Variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#executeBatch(List)that ignores the result of the operation.static SqlTemplate<Map<String,Object>,RowSet<Row>>forQuery(SqlClient client, String template)static SqlTemplate<Map<String,Object>,SqlResult<Void>>forUpdate(SqlClient client, String template)io.vertx.sqlclient.templates.SqlTemplategetDelegate()inthashCode()<T> SqlTemplate<T,R>mapFrom(TupleMapper<T> mapper)<T> SqlTemplate<T,R>mapFrom(Class<T> type)<U> SqlTemplate<I,RowSet<U>>mapTo(RowMapper<U> mapper)<U> SqlTemplate<I,RowSet<U>>mapTo(Class<U> type)static <I,R>
SqlTemplate<I,R>newInstance(io.vertx.sqlclient.templates.SqlTemplate arg)static <I,R>
SqlTemplate<I,R>newInstance(io.vertx.sqlclient.templates.SqlTemplate arg, TypeArg<I> __typeArg_I, TypeArg<R> __typeArg_R)StringtoString()
-
-
-
Method Detail
-
getDelegate
public io.vertx.sqlclient.templates.SqlTemplate getDelegate()
-
forQuery
public static SqlTemplate<Map<String,Object>,RowSet<Row>> forQuery(SqlClient client, String template)
- 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)
- Parameters:
client- the wrapped SQL clienttemplate- the template update string- Returns:
- the template
-
mapFrom
public <T> SqlTemplate<T,R> mapFrom(TupleMapper<T> mapper)
- Parameters:
mapper- the mapping function- Returns:
- a new template
-
mapFrom
public <T> SqlTemplate<T,R> mapFrom(Class<T> type)
- Parameters:
type- the mapping type- Returns:
- a new template
-
mapTo
public <U> SqlTemplate<I,RowSet<U>> mapTo(RowMapper<U> mapper)
- Parameters:
mapper- the mapping function- Returns:
- a new template
-
mapTo
public <U> SqlTemplate<I,RowSet<U>> mapTo(Class<U> type)
- Parameters:
type- the mapping type- Returns:
- a new template
-
execute
public io.smallrye.mutiny.Uni<R> execute(I parameters)
Execute the query with theparametersUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
parameters- the query parameters- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
executeAndAwait
public R executeAndAwait(I parameters)
Blocking variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#execute(I).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
parameters- the query parameters- Returns:
- the R instance produced by the operation.
-
executeAndForget
public void executeAndForget(I parameters)
Variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#execute(I)that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.sqlclient.templates.SqlTemplate#execute(I), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.sqlclient.templates.SqlTemplate#execute(I)but you don't need to compose it with other operations.- Parameters:
parameters- the query parameters
-
executeBatch
public io.smallrye.mutiny.Uni<R> executeBatch(List<I> batch)
Execute a batch query with thebatch.Each item in the batch is mapped to a tuple.
Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Parameters:
batch- the batch- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
executeBatchAndAwait
public R executeBatchAndAwait(List<I> batch)
Blocking variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#executeBatch(List).This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Parameters:
batch- the batch- Returns:
- the R instance produced by the operation.
-
executeBatchAndForget
public void executeBatchAndForget(List<I> batch)
Variant ofio.vertx.mutiny.sqlclient.templates.SqlTemplate#executeBatch(List)that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.sqlclient.templates.SqlTemplate#executeBatch(List), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.sqlclient.templates.SqlTemplate#executeBatch(List)but you don't need to compose it with other operations.- Parameters:
batch- the batch
-
newInstance
public static <I,R> SqlTemplate<I,R> newInstance(io.vertx.sqlclient.templates.SqlTemplate arg)
-
newInstance
public static <I,R> SqlTemplate<I,R> newInstance(io.vertx.sqlclient.templates.SqlTemplate arg, TypeArg<I> __typeArg_I, TypeArg<R> __typeArg_R)
-
-