Class 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 the original non Mutiny-ified interface using Vert.x codegen.

    • Constructor Detail

      • SqlTemplate

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

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

      • getDelegate

        public io.vertx.sqlclient.templates.SqlTemplate getDelegate()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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 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 io.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 of io.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 from io.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 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 io.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 of io.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 from io.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)