Class SqlTemplate<I,R>

java.lang.Object
io.vertx.mutiny.sqlclient.templates.SqlTemplate<I,R>
All Implemented Interfaces:
MutinyDelegate

public class SqlTemplate<I,R> extends Object implements MutinyDelegate
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 original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • SqlTemplate

      public SqlTemplate(io.vertx.sqlclient.templates.SqlTemplate delegate)
    • SqlTemplate

      public SqlTemplate(Object delegate, TypeArg<I> typeArg_0, TypeArg<R> typeArg_1)
    • SqlTemplate

      public SqlTemplate(io.vertx.sqlclient.templates.SqlTemplate delegate, TypeArg<I> typeArg_0, TypeArg<R> typeArg_1)
  • Method Details

    • getDelegate

      public io.vertx.sqlclient.templates.SqlTemplate getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • forQuery

      public static SqlTemplate<Map<String,Object>,RowSet<Row>> forQuery(SqlClient client, String template)
      Parameters:
      client - the wrapped SQL client
      template - 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 client
      template - 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

      @CheckReturnValue public io.smallrye.mutiny.Uni<R> execute(I parameters)
      Execute the query with the parameters

      Unlike 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 uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeAndAwait

      public R executeAndAwait(I parameters)
      Blocking variant of 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 of execute(I) that ignores the result of the operation.

      This method subscribes on the result of execute(I), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from execute(I) but you don't need to compose it with other operations.

      Parameters:
      parameters - the query parameters
    • executeBatch

      @CheckReturnValue public io.smallrye.mutiny.Uni<R> executeBatch(List<I> batch)
      Execute a batch query with the batch.

      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 uni firing the result of the operation when completed, or a failure if the operation failed.
    • executeBatchAndAwait

      public R executeBatchAndAwait(List<I> batch)
      Blocking variant of 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 of executeBatch(List) that ignores the result of the operation.

      This method subscribes on the result of executeBatch(List), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from 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)