Interface SqlOperations

All Known Subinterfaces:
SqlClient, TransactionalSqlOperations
All Known Implementing Classes:
io.inverno.mod.sql.vertx.internal.AbstractSqlClient, io.inverno.mod.sql.vertx.internal.AbstractSqlOperations, ConnectionSqlClient, PooledClientSqlClient, PoolSqlClient

public interface SqlOperations

Specifies basic reactive SQL operations

Since:
1.2
Author:
Jeremy Kuhn
  • Method Summary

    Modifier and Type
    Method
    Description
    batchUpdate(String sql, List<Object[]> args)
    Executes multiple update operations in a batch using the specified list of arguments and returns the number rows affected by the operation.
    Executes multiple update operations in a batch using the specified stream of arguments and returns the number rows affected by the operation.
    Creates a prepared SQL statement.
    query(String sql, Object... args)
    Executes a query operation using a prepared statement with the specified arguments and returns the resulting rows.
    <T> Publisher<T>
    query(String sql, Function<Row,T> rowMapper, Object... args)
    Executes a query operation using a prepared statement with the specified arguments, applies a row mapping function to the resulting rows and returns the results.
    <T> Mono<T>
    queryForObject(String sql, Function<Row,T> rowMapper, Object... args)
    Executes a query operation using a prepared statement with the specified arguments, maps a single row to an object using a row mapping function and return that object.
    Creates a SQL statement.
    update(String sql, Object... args)
    Executes an update operation such as insert, update or delete using a prepared statement with the specified arguments and returns the number rows affected by the operation.
  • Method Details

    • statement

      Statement statement(String sql)

      Creates a SQL statement.

      Parameters:
      sql - the static SQL to execute
      Returns:
      a new statement
    • preparedStatement

      PreparedStatement preparedStatement(String sql)

      Creates a prepared SQL statement.

      Prepared statements are pre-compiled and protect against SQL injection attacks.

      Parameters:
      sql - the SQL to execute
      Returns:
      a new prepared statement
    • query

      Publisher<Row> query(String sql, Object... args)

      Executes a query operation using a prepared statement with the specified arguments and returns the resulting rows.

      Parameters:
      sql - the SQL query to execute
      args - the query arguments
      Returns:
      a publisher of rows
    • query

      <T> Publisher<T> query(String sql, Function<Row,T> rowMapper, Object... args)

      Executes a query operation using a prepared statement with the specified arguments, applies a row mapping function to the resulting rows and returns the results.

      Type Parameters:
      T - the type of results
      Parameters:
      sql - the SQL query to execute
      rowMapper - a row mapping function
      args - the query arguments
      Returns:
      a publisher of results
    • queryForObject

      <T> Mono<T> queryForObject(String sql, Function<Row,T> rowMapper, Object... args)

      Executes a query operation using a prepared statement with the specified arguments, maps a single row to an object using a row mapping function and return that object.

      Type Parameters:
      T - The type of the resulting object
      Parameters:
      sql - the SQL query to execute
      rowMapper - a row mapping function
      args - the query arguments
      Returns:
      a Mono emitting the result
    • update

      Mono<Integer> update(String sql, Object... args)

      Executes an update operation such as insert, update or delete using a prepared statement with the specified arguments and returns the number rows affected by the operation.

      Parameters:
      sql - the SQL update to execute
      args - the update arguments
      Returns:
      a Mono emitting the number of rows affected by the operation
    • batchUpdate

      Mono<Integer> batchUpdate(String sql, List<Object[]> args)

      Executes multiple update operations in a batch using the specified list of arguments and returns the number rows affected by the operation.

      Parameters:
      sql - the SQL update to execute
      args - a list of arguments
      Returns:
      a Mono emitting the number of rows affected by the batch operation
    • batchUpdate

      Mono<Integer> batchUpdate(String sql, Stream<Object[]> args)

      Executes multiple update operations in a batch using the specified stream of arguments and returns the number rows affected by the operation.

      Parameters:
      sql - the SQL update to execute
      args - a stream of arguments
      Returns:
      a Mono emitting the number of rows affected by the batch operation