Interface R2dbcEntityOperations

All Superinterfaces:
FluentR2dbcOperations, ReactiveDeleteOperation, ReactiveInsertOperation, ReactiveSelectOperation, ReactiveUpdateOperation
All Known Implementing Classes:
R2dbcEntityTemplate

public interface R2dbcEntityOperations extends FluentR2dbcOperations
Interface specifying a basic set of reactive R2DBC operations using entities. Implemented by R2dbcEntityTemplate. Not often used directly, but a useful option to enhance testability, as it can easily be mocked or stubbed.
Since:
1.1
Author:
Mark Paluch
See Also:
  • Method Details

    • getDatabaseClient

      DatabaseClient getDatabaseClient()
      Expose the underlying DatabaseClient to allow SQL operations.
      Returns:
      the underlying DatabaseClient.
      See Also:
    • getDataAccessStrategy

      @Deprecated ReactiveDataAccessStrategy getDataAccessStrategy()
      Deprecated.
      use getConverter() instead as ReactiveDataAccessStrategy will be removed in a future release.
      Expose the underlying ReactiveDataAccessStrategy encapsulating dialect specifics.
      Returns:
      the underlying ReactiveDataAccessStrategy.
      Since:
      1.1.3
      See Also:
    • getConverter

      R2dbcConverter getConverter()
      Return the underlying R2dbcConverter.
      Returns:
      the underlying R2dbcConverter.
      Since:
      1.2
    • count

      reactor.core.publisher.Mono<Long> count(org.springframework.data.relational.core.query.Query query, Class<?> entityClass) throws DataAccessException
      Returns the number of rows for the given entity class applying Query. This overridden method allows users to further refine the selection Query using a Query predicate to determine how many entities of the given type match the Query.
      Parameters:
      query - user-defined count Query to execute; must not be null.
      entityClass - type of the entity; must not be null.
      Returns:
      the number of existing entities.
      Throws:
      DataAccessException - if any problem occurs while executing the query.
    • exists

      reactor.core.publisher.Mono<Boolean> exists(org.springframework.data.relational.core.query.Query query, Class<?> entityClass) throws DataAccessException
      Determine whether the result for entityClass Query yields at least one row.
      Parameters:
      query - user-defined exists Query to execute; must not be null.
      entityClass - type of the entity; must not be null.
      Returns:
      true if the object exists.
      Throws:
      DataAccessException - if any problem occurs while executing the query.
      Since:
      2.1
    • select

      <T> reactor.core.publisher.Flux<T> select(org.springframework.data.relational.core.query.Query query, Class<T> entityClass) throws DataAccessException
      Execute a SELECT query and convert the resulting items to a stream of entities.
      Parameters:
      query - must not be null.
      entityClass - the entity type must not be null.
      Returns:
      the result objects returned by the action.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
    • selectOne

      <T> reactor.core.publisher.Mono<T> selectOne(org.springframework.data.relational.core.query.Query query, Class<T> entityClass) throws DataAccessException
      Execute a SELECT query and convert the resulting item to an entity ensuring exactly one result.
      Parameters:
      query - must not be null.
      entityClass - the entity type must not be null.
      Returns:
      exactly one result or Mono.empty() if no match found.
      Throws:
      IncorrectResultSizeDataAccessException - if more than one match found.
      DataAccessException - if there is any problem issuing the execution.
    • update

      reactor.core.publisher.Mono<Long> update(org.springframework.data.relational.core.query.Query query, org.springframework.data.relational.core.query.Update update, Class<?> entityClass) throws DataAccessException
      Update the queried entities and return true if the update was applied.
      Parameters:
      query - must not be null.
      update - must not be null.
      entityClass - the entity type must not be null.
      Returns:
      the number of affected rows.
      Throws:
      DataAccessException - if there is any problem executing the query.
    • delete

      reactor.core.publisher.Mono<Long> delete(org.springframework.data.relational.core.query.Query query, Class<?> entityClass) throws DataAccessException
      Remove entities (rows)/columns from the table by Query.
      Parameters:
      query - must not be null.
      entityClass - the entity type must not be null.
      Returns:
      the number of affected rows.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
    • query

      <T> RowsFetchSpec<T> query(PreparedOperation<?> operation, Class<T> entityClass) throws DataAccessException
      Execute a query for a RowsFetchSpec, given PreparedOperation. Any provided bindings within PreparedOperation are applied to the underlying DatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped onto entityClass.
      Parameters:
      operation - the prepared operation wrapping a SQL query and bind parameters.
      entityClass - the entity type must not be null.
      Returns:
      a RowsFetchSpec ready to materialize.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
      Since:
      1.4
    • query

      default <T> RowsFetchSpec<T> query(PreparedOperation<?> operation, Function<Row,T> rowMapper) throws DataAccessException
      Execute a query for a RowsFetchSpec, given PreparedOperation. Any provided bindings within PreparedOperation are applied to the underlying DatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped using rowMapper.
      Parameters:
      operation - the prepared operation wrapping a SQL query and bind parameters.
      rowMapper - the row mapper must not be null.
      Returns:
      a RowsFetchSpec with rowMapper applied ready to materialize.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
      Since:
      1.4
      See Also:
    • query

      <T> RowsFetchSpec<T> query(PreparedOperation<?> operation, BiFunction<Row,RowMetadata,T> rowMapper) throws DataAccessException
      Execute a query for a RowsFetchSpec, given PreparedOperation. Any provided bindings within PreparedOperation are applied to the underlying DatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped using rowMapper.
      Parameters:
      operation - the prepared operation wrapping a SQL query and bind parameters.
      rowMapper - the row mapper must not be null.
      Returns:
      a RowsFetchSpec with rowMapper applied ready to materialize.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
      Since:
      1.4
    • query

      default <T> RowsFetchSpec<T> query(PreparedOperation<?> operation, Class<?> entityClass, Function<Row,T> rowMapper) throws DataAccessException
      Execute a query for a RowsFetchSpec in the context of entityClass, given PreparedOperation. Any provided bindings within PreparedOperation are applied to the underlying DatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped using rowMapper.
      Parameters:
      operation - the prepared operation wrapping a SQL query and bind parameters.
      entityClass - the entity type must not be null.
      rowMapper - the row mapper must not be null.
      Returns:
      a RowsFetchSpec with rowMapper applied ready to materialize.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
      Since:
      1.4
      See Also:
    • query

      <T> RowsFetchSpec<T> query(PreparedOperation<?> operation, Class<?> entityClass, BiFunction<Row,RowMetadata,T> rowMapper) throws DataAccessException
      Execute a query for a RowsFetchSpec in the context of entityClass, given PreparedOperation. Any provided bindings within PreparedOperation are applied to the underlying DatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped using rowMapper.
      Parameters:
      operation - the prepared operation wrapping a SQL query and bind parameters.
      entityClass - the entity type must not be null.
      rowMapper - the row mapper must not be null.
      Returns:
      a RowsFetchSpec with rowMapper applied ready to materialize.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
      Since:
      1.4
      See Also:
    • insert

      <T> reactor.core.publisher.Mono<T> insert(T entity) throws DataAccessException
      Insert the given entity and emit the entity if the insert was applied.
      Parameters:
      entity - the entity to insert, must not be null.
      Returns:
      the inserted entity.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
    • update

      <T> reactor.core.publisher.Mono<T> update(T entity) throws DataAccessException
      Update the given entity and emit the entity if the update was applied.
      Parameters:
      entity - the entity to update, must not be null.
      Returns:
      the updated entity.
      Throws:
      DataAccessException - if there is any problem issuing the execution.
      TransientDataAccessResourceException - if the update did not affect any rows.
    • delete

      <T> reactor.core.publisher.Mono<T> delete(T entity) throws DataAccessException
      Delete the given entity and emit the entity if the delete was applied.
      Parameters:
      entity - must not be null.
      Returns:
      the deleted entity.
      Throws:
      DataAccessException - if there is any problem issuing the execution.