Interface ReactiveStreamsCrudRepository<E,ID>

Type Parameters:
E - The entity type
ID - The ID type
All Superinterfaces:
GenericRepository<E,ID>
All Known Subinterfaces:
ReactiveStreamsPageableRepository<E,ID>, ReactorCrudRepository<E,ID>, ReactorCrudRepository<E,ID>, ReactorPageableRepository<E,ID>

public interface ReactiveStreamsCrudRepository<E,ID> extends GenericRepository<E,ID>
Interface for CRUD using Reactive Streams.
Since:
1.0.0
Author:
graemerocher
  • Method Summary

    Modifier and Type
    Method
    Description
    org.reactivestreams.Publisher<Long>
    Returns the number of entities available.
    org.reactivestreams.Publisher<Long>
    delete(E entity)
    Deletes a given entity.
    org.reactivestreams.Publisher<Long>
    Deletes all entities managed by the repository.
    org.reactivestreams.Publisher<Long>
    deleteAll(@NotNull Iterable<? extends E> entities)
    Deletes the given entities.
    org.reactivestreams.Publisher<Long>
    Deletes the entity with the given id.
    org.reactivestreams.Publisher<Boolean>
    Returns whether an entity with the given id exists.
    org.reactivestreams.Publisher<E>
    Returns all instances of the type.
    org.reactivestreams.Publisher<E>
    Retrieves an entity by its id.
    <S extends E>
    org.reactivestreams.Publisher<S>
    save(S entity)
    Saves the given valid entity, returning a possibly new entity representing the saved state.
    <S extends E>
    org.reactivestreams.Publisher<S>
    saveAll(@Valid @NotNull Iterable<S> entities)
    Saves all given entities, possibly returning new instances representing the saved state.
    <S extends E>
    org.reactivestreams.Publisher<S>
    update(S entity)
    This method issues an explicit update for the given entity.
    <S extends E>
    org.reactivestreams.Publisher<S>
    updateAll(@Valid @NotNull Iterable<S> entities)
    This method issues an explicit update for the given entities.
  • Method Details

    • save

      @NonNull @SingleResult <S extends E> org.reactivestreams.Publisher<S> save(@Valid @NotNull @NonNull S entity)
      Saves the given valid entity, returning a possibly new entity representing the saved state.
      Type Parameters:
      S - The generic type
      Parameters:
      entity - The entity to save. Must not be null.
      Returns:
      The saved entity will never be null.
      Throws:
      jakarta.validation.ConstraintViolationException - if the entity is null or invalid.
    • saveAll

      @NonNull <S extends E> org.reactivestreams.Publisher<S> saveAll(@Valid @NotNull @NonNull @Valid @NotNull Iterable<S> entities)
      Saves all given entities, possibly returning new instances representing the saved state.
      Type Parameters:
      S - The generic type
      Parameters:
      entities - The entities to saved. Must not be null.
      Returns:
      The saved entities objects. will never be null.
      Throws:
      jakarta.validation.ConstraintViolationException - if the entities are null.
    • update

      @NonNull <S extends E> org.reactivestreams.Publisher<S> update(@Valid @NotNull @NonNull S entity)
      This method issues an explicit update for the given entity. The method differs from save(Object) in that an update will be generated regardless if the entity has been saved previously or not. If the entity has no assigned ID then an exception will be thrown.
      Type Parameters:
      S - The generic type
      Parameters:
      entity - The entity to update. Must not be null.
      Returns:
      The updated entity will never be null.
      Throws:
      jakarta.validation.ConstraintViolationException - if the entity is null or invalid.
    • updateAll

      @NonNull <S extends E> org.reactivestreams.Publisher<S> updateAll(@Valid @NotNull @NonNull @Valid @NotNull Iterable<S> entities)
      This method issues an explicit update for the given entities. The method differs from saveAll(Iterable) in that an update will be generated regardless if the entity has been saved previously or not. If the entity has no assigned ID then an exception will be thrown.
      Type Parameters:
      S - The generic type
      Parameters:
      entities - The entities to update. Must not be null.
      Returns:
      The updated entities will never be null.
      Throws:
      jakarta.validation.ConstraintViolationException - if entities is null or invalid.
    • findById

      @NonNull @SingleResult org.reactivestreams.Publisher<E> findById(@NotNull @NonNull ID id)
      Retrieves an entity by its id.
      Parameters:
      id - The ID of the entity to retrieve. Must not be null.
      Returns:
      the entity with the given id or Optional#empty() if none found
      Throws:
      jakarta.validation.ConstraintViolationException - if the id is null.
    • existsById

      @SingleResult @NonNull org.reactivestreams.Publisher<Boolean> existsById(@NotNull @NonNull ID id)
      Returns whether an entity with the given id exists.
      Parameters:
      id - must not be null.
      Returns:
      true if an entity with the given id exists, false otherwise.
      Throws:
      jakarta.validation.ConstraintViolationException - if the id is null.
    • findAll

      @NonNull org.reactivestreams.Publisher<E> findAll()
      Returns all instances of the type.
      Returns:
      all entities
    • count

      @SingleResult @NonNull org.reactivestreams.Publisher<Long> count()
      Returns the number of entities available.
      Returns:
      the number of entities
    • deleteById

      @NonNull @SingleResult org.reactivestreams.Publisher<Long> deleteById(@NonNull @NotNull ID id)
      Deletes the entity with the given id.
      Parameters:
      id - must not be null.
      Returns:
      A future that executes the delete operation
      Throws:
      jakarta.validation.ConstraintViolationException - if the entity is null.
    • delete

      @SingleResult @NonNull org.reactivestreams.Publisher<Long> delete(@NonNull @NotNull E entity)
      Deletes a given entity.
      Parameters:
      entity - The entity to delete
      Returns:
      A future that executes the delete operation
      Throws:
      jakarta.validation.ConstraintViolationException - if the entity is null.
    • deleteAll

      @SingleResult @NonNull org.reactivestreams.Publisher<Long> deleteAll(@NonNull @NotNull @NotNull Iterable<? extends E> entities)
      Deletes the given entities.
      Parameters:
      entities - The entities to delete
      Returns:
      A future that executes the delete operation
      Throws:
      jakarta.validation.ConstraintViolationException - if the entity is null.
    • deleteAll

      @NonNull org.reactivestreams.Publisher<Long> deleteAll()
      Deletes all entities managed by the repository.
      Returns:
      A future that executes the delete operation