@NoRepositoryBean public interface ReactiveCrudRepository<T,ID> extends Repository<T,ID>
Save and delete operations with entities that have a version attribute trigger an onError
with a
OptimisticLockingFailureException
when they encounter a different version value in
the persistence store than in the entity passed as an argument.
Other delete operations that only receive ids or entities without version attribute do not trigger an error when no matching data is found in the persistence store.
Mono
,
Flux
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<Long> |
count()
Returns the number of entities available.
|
reactor.core.publisher.Mono<Void> |
delete(T entity)
Deletes a given entity.
|
reactor.core.publisher.Mono<Void> |
deleteAll()
Deletes all entities managed by the repository.
|
reactor.core.publisher.Mono<Void> |
deleteAll(Iterable<? extends T> entities)
Deletes the given entities.
|
reactor.core.publisher.Mono<Void> |
deleteAll(org.reactivestreams.Publisher<? extends T> entityStream)
Deletes the given entities supplied by a
Publisher . |
reactor.core.publisher.Mono<Void> |
deleteAllById(Iterable<? extends ID> ids)
Deletes all instances of the type
T with the given IDs. |
reactor.core.publisher.Mono<Void> |
deleteById(ID id)
Deletes the entity with the given id.
|
reactor.core.publisher.Mono<Void> |
deleteById(org.reactivestreams.Publisher<ID> id)
Deletes the entity with the given id supplied by a
Publisher . |
reactor.core.publisher.Mono<Boolean> |
existsById(ID id)
Returns whether an entity with the given id exists.
|
reactor.core.publisher.Mono<Boolean> |
existsById(org.reactivestreams.Publisher<ID> id)
Returns whether an entity with the given id, supplied by a
Publisher , exists. |
reactor.core.publisher.Flux<T> |
findAll()
Returns all instances of the type.
|
reactor.core.publisher.Flux<T> |
findAllById(Iterable<ID> ids)
Returns all instances of the type
T with the given IDs. |
reactor.core.publisher.Flux<T> |
findAllById(org.reactivestreams.Publisher<ID> idStream)
Returns all instances of the type
T with the given IDs supplied by a Publisher . |
reactor.core.publisher.Mono<T> |
findById(ID id)
Retrieves an entity by its id.
|
reactor.core.publisher.Mono<T> |
findById(org.reactivestreams.Publisher<ID> id)
Retrieves an entity by its id supplied by a
Publisher . |
<S extends T> |
save(S entity)
Saves a given entity.
|
<S extends T> |
saveAll(Iterable<S> entities)
Saves all given entities.
|
<S extends T> |
saveAll(org.reactivestreams.Publisher<S> entityStream)
Saves all given entities.
|
<S extends T> reactor.core.publisher.Mono<S> save(S entity)
entity
- must not be null.Mono
emitting the saved entity.IllegalArgumentException
- in case the given entity is null.OptimisticLockingFailureException
- when the entity uses optimistic locking and has a version attribute with
a different value from that found in the persistence store. Also thrown if the entity is assumed to be
present but does not exist in the database.<S extends T> reactor.core.publisher.Flux<S> saveAll(Iterable<S> entities)
entities
- must not be null.Flux
emitting the saved entities.IllegalArgumentException
- in case the given entities
or one of its entities is
null.OptimisticLockingFailureException
- when at least one entity uses optimistic locking and has a version
attribute with a different value from that found in the persistence store. Also thrown if at least one
entity is assumed to be present but does not exist in the database.<S extends T> reactor.core.publisher.Flux<S> saveAll(org.reactivestreams.Publisher<S> entityStream)
entityStream
- must not be null.Flux
emitting the saved entities.IllegalArgumentException
- in case the given entityStream
is null.OptimisticLockingFailureException
- when at least one entity uses optimistic locking and has a version
attribute with a different value from that found in the persistence store. Also thrown if at least one
entity is assumed to be present but does not exist in the database.reactor.core.publisher.Mono<T> findById(ID id)
id
- must not be null.Mono
emitting the entity with the given id or Mono.empty()
if none found.IllegalArgumentException
- in case the given id is null.reactor.core.publisher.Mono<T> findById(org.reactivestreams.Publisher<ID> id)
Publisher
.id
- must not be null. Uses the first emitted element to perform the find-query.Mono
emitting the entity with the given id or Mono.empty()
if none found.IllegalArgumentException
- in case the given id
is null.reactor.core.publisher.Mono<Boolean> existsById(ID id)
id
- must not be null.Mono
emitting true if an entity with the given id exists, false otherwise.IllegalArgumentException
- in case the given id is null.reactor.core.publisher.Mono<Boolean> existsById(org.reactivestreams.Publisher<ID> id)
Publisher
, exists. Uses the first emitted
element to perform the exists-query.id
- must not be null.Mono
emitting true if an entity with the given id exists, false otherwise.IllegalArgumentException
- in case the given id
is null.reactor.core.publisher.Flux<T> findAll()
Flux
emitting all entities.reactor.core.publisher.Flux<T> findAllById(Iterable<ID> ids)
T
with the given IDs.
If some or all ids are not found, no entities are returned for these IDs.
Note that the order of elements in the result is not guaranteed.
ids
- must not be null nor contain any null values.Flux
emitting the found entities. The size can be equal or less than the number of given
ids.IllegalArgumentException
- in case the given ids
or one of its items is null.reactor.core.publisher.Flux<T> findAllById(org.reactivestreams.Publisher<ID> idStream)
T
with the given IDs supplied by a Publisher
.
If some or all ids are not found, no entities are returned for these IDs.
Note that the order of elements in the result is not guaranteed.
idStream
- must not be null.Flux
emitting the found entities.IllegalArgumentException
- in case the given idStream
is null.reactor.core.publisher.Mono<Long> count()
Mono
emitting the number of entities.reactor.core.publisher.Mono<Void> deleteById(ID id)
If the entity is not found in the persistence store it is silently ignored.
id
- must not be null.Mono
signaling when operation has completed.IllegalArgumentException
- in case the given id is null.reactor.core.publisher.Mono<Void> deleteById(org.reactivestreams.Publisher<ID> id)
Publisher
.
If the entity is not found in the persistence store it is silently ignored.
id
- must not be null.Mono
signaling when operation has completed.IllegalArgumentException
- in case the given id
is null.reactor.core.publisher.Mono<Void> delete(T entity)
entity
- must not be null.Mono
signaling when operation has completed.IllegalArgumentException
- in case the given entity is null.OptimisticLockingFailureException
- when the entity uses optimistic locking and has a version attribute with
a different value from that found in the persistence store. Also thrown if the entity is assumed to be
present but does not exist in the database.reactor.core.publisher.Mono<Void> deleteAllById(Iterable<? extends ID> ids)
T
with the given IDs.
Entities that aren't found in the persistence store are silently ignored.
ids
- must not be null.Mono
signaling when operation has completed.IllegalArgumentException
- in case the given ids or one of its elements is null.
null.reactor.core.publisher.Mono<Void> deleteAll(Iterable<? extends T> entities)
entities
- must not be null.Mono
signaling when operation has completed.IllegalArgumentException
- in case the given entities
or one of its entities is
null.OptimisticLockingFailureException
- when at least one entity uses optimistic locking and has a version
attribute with a different value from that found in the persistence store. Also thrown if at least one
entity is assumed to be present but does not exist in the database.reactor.core.publisher.Mono<Void> deleteAll(org.reactivestreams.Publisher<? extends T> entityStream)
Publisher
.entityStream
- must not be null.Mono
signaling when operation has completed.IllegalArgumentException
- in case the given entityStream
is null.OptimisticLockingFailureException
- when at least one entity uses optimistic locking and has a version
attribute with a different value from that found in the persistence store. Also thrown if at least one
entity is assumed to be present but does not exist in the database.reactor.core.publisher.Mono<Void> deleteAll()
Mono
signaling when operation has completed.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.