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.TerminatingDelete
Nested 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 TypeMethodDescriptionReturns the number of rows for the given entity class applyingQuery
.Remove entities (rows)/columns from the table byQuery
.<T> Mono<T>
delete
(T entity) Delete the given entity and emit the entity if the delete was applied.Determine whether the result forentityClass
Query
yields at least one row.Return the underlyingR2dbcConverter
.Deprecated.Expose the underlyingDatabaseClient
to allow SQL operations.<T> RowsFetchSpec<T>
getRowsFetchSpec
(DatabaseClient.GenericExecuteSpec executeSpec, Class<?> entityType, Class<T> resultType) <T> 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<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, T> rowMapper) default <T> RowsFetchSpec<T>
query
(PreparedOperation<?> operation, Class<?> entityClass, Function<io.r2dbc.spi.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<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, T> rowMapper) Execute a query for aRowsFetchSpec
, givenPreparedOperation
.default <T> RowsFetchSpec<T>
query
(PreparedOperation<?> operation, Function<io.r2dbc.spi.Row, T> rowMapper) Execute a query for aRowsFetchSpec
, givenPreparedOperation
.<T> Flux<T>
Execute aSELECT
query and convert the resulting items to a stream of entities.<T> Mono<T>
Execute aSELECT
query and convert the resulting item to an entity ensuring exactly one result.Update the queried entities and return true if the update was applied.<T> 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
delete
Methods inherited from interface org.springframework.data.r2dbc.core.ReactiveInsertOperation
insert
Methods inherited from interface org.springframework.data.r2dbc.core.ReactiveSelectOperation
select
Methods inherited from interface org.springframework.data.r2dbc.core.ReactiveUpdateOperation
update
-
Method Details
-
getDatabaseClient
DatabaseClient getDatabaseClient()Expose the underlyingDatabaseClient
to allow SQL operations.- Returns:
- the underlying
DatabaseClient
. - See Also:
-
getDataAccessStrategy
Deprecated.usegetConverter()
instead asReactiveDataAccessStrategy
will be removed in a future release.Expose the underlyingReactiveDataAccessStrategy
encapsulating 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
Returns the number of rows for the given entity class applyingQuery
. This overridden method allows users to further refine the selection Query using aQuery
predicate to determine how many entities of the giventype
match the Query.- Parameters:
query
- user-defined countQuery
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
Determine whether the result forentityClass
Query
yields at least one row.- Parameters:
query
- user-defined existsQuery
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
Execute aSELECT
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
Execute aSELECT
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
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
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 withinPreparedOperation
are 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
RowsFetchSpec
ready 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 withinPreparedOperation
are 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
RowsFetchSpec
ready 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<io.r2dbc.spi.Row, T> rowMapper) throws DataAccessExceptionExecute a query for aRowsFetchSpec
, givenPreparedOperation
. Any provided bindings withinPreparedOperation
are 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
RowsFetchSpec
withrowMapper
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<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, throws DataAccessExceptionT> rowMapper) Execute a query for aRowsFetchSpec
, givenPreparedOperation
. Any provided bindings withinPreparedOperation
are 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
RowsFetchSpec
withrowMapper
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<io.r2dbc.spi.Row, T> rowMapper) throws DataAccessExceptionExecute a query for aRowsFetchSpec
in the context ofentityClass
, givenPreparedOperation
. Any provided bindings withinPreparedOperation
are 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
RowsFetchSpec
withrowMapper
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<io.r2dbc.spi.Row, io.r2dbc.spi.RowMetadata, throws DataAccessExceptionT> rowMapper) Execute a query for aRowsFetchSpec
in the context ofentityClass
, givenPreparedOperation
. Any provided bindings withinPreparedOperation
are 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
RowsFetchSpec
withrowMapper
applied 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 asReactiveDataAccessStrategy
will be removed in a future release.