Module spring.data.r2dbc
Interface R2dbcEntityOperations
- All Superinterfaces:
FluentR2dbcOperations,ReactiveDeleteOperation,ReactiveInsertOperation,ReactiveSelectOperation,ReactiveUpdateOperation
- All Known Implementing Classes:
R2dbcEntityTemplate
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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.r2dbc.core.ReactiveDeleteOperation
ReactiveDeleteOperation.DeleteWithQuery, ReactiveDeleteOperation.DeleteWithTable, ReactiveDeleteOperation.ReactiveDelete, ReactiveDeleteOperation.TerminatingDeleteNested classes/interfaces inherited from interface org.springframework.data.r2dbc.core.ReactiveInsertOperation
ReactiveInsertOperation.InsertWithTable<T>, ReactiveInsertOperation.ReactiveInsert<T>, ReactiveInsertOperation.TerminatingInsert<T>Nested classes/interfaces inherited from interface org.springframework.data.r2dbc.core.ReactiveSelectOperation
ReactiveSelectOperation.ReactiveSelect<T>, ReactiveSelectOperation.SelectWithProjection<T>, ReactiveSelectOperation.SelectWithQuery<T>, ReactiveSelectOperation.SelectWithTable<T>, ReactiveSelectOperation.TerminatingSelect<T>Nested classes/interfaces inherited from interface org.springframework.data.r2dbc.core.ReactiveUpdateOperation
ReactiveUpdateOperation.ReactiveUpdate, ReactiveUpdateOperation.TerminatingUpdate, ReactiveUpdateOperation.UpdateWithQuery, ReactiveUpdateOperation.UpdateWithTable -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Long>Returns the number of rows for the given entity class applyingQuery.reactor.core.publisher.Mono<Long>Remove entities (rows)/columns from the table byQuery.<T> reactor.core.publisher.Mono<T>delete(T entity) Delete the given entity and emit the entity if the delete was applied.reactor.core.publisher.Mono<Boolean>Determine whether the result forentityClassQueryyields at least one row.Return the underlyingR2dbcConverter.Deprecated.Expose the underlyingDatabaseClientto allow SQL operations.<T> RowsFetchSpec<T>getRowsFetchSpec(DatabaseClient.GenericExecuteSpec executeSpec, Class<?> entityType, Class<T> resultType) <T> reactor.core.publisher.Mono<T>insert(T entity) Insert the given entity and emit the entity if the insert was applied.<T> RowsFetchSpec<T>query(PreparedOperation<?> operation, Class<?> entityClass, Class<T> resultType) Execute a query for aRowsFetchSpec, givenPreparedOperation.<T> RowsFetchSpec<T>query(PreparedOperation<?> operation, Class<?> entityClass, BiFunction<Row, RowMetadata, T> rowMapper) default <T> RowsFetchSpec<T>query(PreparedOperation<?> operation, Class<?> entityClass, Function<Row, T> rowMapper) <T> RowsFetchSpec<T>query(PreparedOperation<?> operation, Class<T> entityClass) Execute a query for aRowsFetchSpec, givenPreparedOperation.<T> RowsFetchSpec<T>query(PreparedOperation<?> operation, BiFunction<Row, RowMetadata, T> rowMapper) Execute a query for aRowsFetchSpec, givenPreparedOperation.default <T> RowsFetchSpec<T>query(PreparedOperation<?> operation, Function<Row, T> rowMapper) Execute a query for aRowsFetchSpec, givenPreparedOperation.<T> reactor.core.publisher.Flux<T>Execute aSELECTquery and convert the resulting items to a stream of entities.<T> reactor.core.publisher.Mono<T>Execute aSELECTquery and convert the resulting item to an entity ensuring exactly one result.reactor.core.publisher.Mono<Long>update(org.springframework.data.relational.core.query.Query query, org.springframework.data.relational.core.query.Update update, Class<?> entityClass) Update the queried entities and return true if the update was applied.<T> reactor.core.publisher.Mono<T>update(T entity) Update the given entity and emit the entity if the update was applied.Methods inherited from interface org.springframework.data.r2dbc.core.ReactiveDeleteOperation
deleteMethods inherited from interface org.springframework.data.r2dbc.core.ReactiveInsertOperation
insertMethods inherited from interface org.springframework.data.r2dbc.core.ReactiveSelectOperation
selectMethods inherited from interface org.springframework.data.r2dbc.core.ReactiveUpdateOperation
update
-
Method Details
-
getDatabaseClient
DatabaseClient getDatabaseClient()Expose the underlyingDatabaseClientto allow SQL operations.- Returns:
- the underlying
DatabaseClient. - See Also:
-
getDataAccessStrategy
Deprecated.usegetConverter()instead asReactiveDataAccessStrategywill be removed in a future release.Expose the underlyingReactiveDataAccessStrategyencapsulating dialect specifics.- Returns:
- the underlying
ReactiveDataAccessStrategy. - Since:
- 1.1.3
- See Also:
-
getConverter
R2dbcConverter getConverter()Return the underlyingR2dbcConverter.- 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 applyingQuery. This overridden method allows users to further refine the selection Query using aQuerypredicate to determine how many entities of the giventypematch the Query.- Parameters:
query- user-defined countQueryto execute; must not be null.entityClass-typeof 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 forentityClassQueryyields at least one row.- Parameters:
query- user-defined existsQueryto execute; must not be null.entityClass-typeof 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 aSELECTquery 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 aSELECTquery 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 byQuery.- 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 aRowsFetchSpec, givenPreparedOperation. Any provided bindings withinPreparedOperationare applied to the underlyingDatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped ontoentityClass.- Parameters:
operation- the prepared operation wrapping a SQL query and bind parameters.entityClass- the entity type must not be null.- Returns:
- a
RowsFetchSpecready to materialize. - Throws:
DataAccessException- if there is any problem issuing the execution.- Since:
- 1.4
-
query
<T> RowsFetchSpec<T> query(PreparedOperation<?> operation, Class<?> entityClass, Class<T> resultType) throws DataAccessException Execute a query for aRowsFetchSpec, givenPreparedOperation. Any provided bindings withinPreparedOperationare applied to the underlyingDatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped ontoentityClass.- Parameters:
operation- the prepared operation wrapping a SQL query and bind parameters.entityClass- the entity type must not be null.resultType- the returned entity, type must not be null.- Returns:
- a
RowsFetchSpecready to materialize. - Throws:
DataAccessException- if there is any problem issuing the execution.- Since:
- 3.2.1
-
query
default <T> RowsFetchSpec<T> query(PreparedOperation<?> operation, Function<Row, T> rowMapper) throws DataAccessExceptionExecute a query for aRowsFetchSpec, givenPreparedOperation. Any provided bindings withinPreparedOperationare applied to the underlyingDatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped usingrowMapper.- Parameters:
operation- the prepared operation wrapping a SQL query and bind parameters.rowMapper- the row mapper must not be null.- Returns:
- a
RowsFetchSpecwithrowMapperapplied 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, throws DataAccessExceptionT> rowMapper) Execute a query for aRowsFetchSpec, givenPreparedOperation. Any provided bindings withinPreparedOperationare applied to the underlyingDatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped usingrowMapper.- Parameters:
operation- the prepared operation wrapping a SQL query and bind parameters.rowMapper- the row mapper must not be null.- Returns:
- a
RowsFetchSpecwithrowMapperapplied 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 DataAccessExceptionExecute a query for aRowsFetchSpecin the context ofentityClass, givenPreparedOperation. Any provided bindings withinPreparedOperationare applied to the underlyingDatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped usingrowMapper.- 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
RowsFetchSpecwithrowMapperapplied 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, throws DataAccessExceptionT> rowMapper) Execute a query for aRowsFetchSpecin the context ofentityClass, givenPreparedOperation. Any provided bindings withinPreparedOperationare applied to the underlyingDatabaseClient. The query is issued as-is without additional pre-processing such as named parameter expansion. Results of the query are mapped usingrowMapper.- 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
RowsFetchSpecwithrowMapperapplied ready to materialize. - Throws:
DataAccessException- if there is any problem issuing the execution.- Since:
- 1.4
- See Also:
-
getRowsFetchSpec
<T> RowsFetchSpec<T> getRowsFetchSpec(DatabaseClient.GenericExecuteSpec executeSpec, Class<?> entityType, Class<T> resultType) -
insert
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
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
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.
-
getConverter()instead asReactiveDataAccessStrategywill be removed in a future release.