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:
-
DatabaseClient
-
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.org.springframework.r2dbc.core.DatabaseClientExpose the underlyingDatabaseClientto allow SQL operations.<T> reactor.core.publisher.Mono<T>insert(T entity) Insert the given entity and emit the entity if the insert was applied.<T> org.springframework.r2dbc.core.RowsFetchSpec<T>query(org.springframework.r2dbc.core.PreparedOperation<?> operation, Class<?> entityClass, BiFunction<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, T> rowMapper) Execute a query for aRowsFetchSpecin the context ofentityClass, givenPreparedOperation.default <T> org.springframework.r2dbc.core.RowsFetchSpec<T>query(org.springframework.r2dbc.core.PreparedOperation<?> operation, Class<?> entityClass, Function<io.r2dbc.spi.Row, T> rowMapper) Execute a query for aRowsFetchSpecin the context ofentityClass, givenPreparedOperation.<T> org.springframework.r2dbc.core.RowsFetchSpec<T>Execute a query for aRowsFetchSpec, givenPreparedOperation.<T> org.springframework.r2dbc.core.RowsFetchSpec<T>query(org.springframework.r2dbc.core.PreparedOperation<?> operation, BiFunction<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, T> rowMapper) Execute a query for aRowsFetchSpec, givenPreparedOperation.default <T> org.springframework.r2dbc.core.RowsFetchSpec<T>query(org.springframework.r2dbc.core.PreparedOperation<?> operation, Function<io.r2dbc.spi.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 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
org.springframework.r2dbc.core.DatabaseClient getDatabaseClient()Expose the underlyingDatabaseClientto allow SQL operations.- Returns:
- the underlying
DatabaseClient. - See Also:
-
DatabaseClient
-
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(Query query, Class<?> entityClass) throws org.springframework.dao.DataAccessException -
exists
reactor.core.publisher.Mono<Boolean> exists(Query query, Class<?> entityClass) throws org.springframework.dao.DataAccessException Determine whether the result forentityClassQueryyields at least one row. -
select
<T> reactor.core.publisher.Flux<T> select(Query query, Class<T> entityClass) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.
-
selectOne
<T> reactor.core.publisher.Mono<T> selectOne(Query query, Class<T> entityClass) throws org.springframework.dao.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:
org.springframework.dao.IncorrectResultSizeDataAccessException- if more than one match found.org.springframework.dao.DataAccessException- if there is any problem issuing the execution.
-
update
reactor.core.publisher.Mono<Long> update(Query query, Update update, Class<?> entityClass) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem executing the query.
-
delete
reactor.core.publisher.Mono<Long> delete(Query query, Class<?> entityClass) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.
-
query
<T> org.springframework.r2dbc.core.RowsFetchSpec<T> query(org.springframework.r2dbc.core.PreparedOperation<?> operation, Class<T> entityClass) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.- Since:
- 1.4
-
query
default <T> org.springframework.r2dbc.core.RowsFetchSpec<T> query(org.springframework.r2dbc.core.PreparedOperation<?> operation, Function<io.r2dbc.spi.Row, T> rowMapper) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.- Since:
- 1.4
- See Also:
-
query
<T> org.springframework.r2dbc.core.RowsFetchSpec<T> query(org.springframework.r2dbc.core.PreparedOperation<?> operation, BiFunction<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.- Since:
- 1.4
-
query
default <T> org.springframework.r2dbc.core.RowsFetchSpec<T> query(org.springframework.r2dbc.core.PreparedOperation<?> operation, Class<?> entityClass, Function<io.r2dbc.spi.Row, T> rowMapper) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.- Since:
- 1.4
- See Also:
-
query
<T> org.springframework.r2dbc.core.RowsFetchSpec<T> query(org.springframework.r2dbc.core.PreparedOperation<?> operation, Class<?> entityClass, BiFunction<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, throws org.springframework.dao.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:
org.springframework.dao.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 org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.
-
update
<T> reactor.core.publisher.Mono<T> update(T entity) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.org.springframework.dao.TransientDataAccessResourceException- if the update did not affect any rows.
-
delete
<T> reactor.core.publisher.Mono<T> delete(T entity) throws org.springframework.dao.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:
org.springframework.dao.DataAccessException- if there is any problem issuing the execution.
-
getConverter()instead asReactiveDataAccessStrategywill be removed in a future release.