Interface AsyncCrudRepository<T,​ID>

  • Type Parameters:
    T - the domain type the repository manages
    ID - the type of the id of the entity the repository manages
    All Superinterfaces:
    org.springframework.data.repository.Repository<T,​ID>
    All Known Subinterfaces:
    CoherenceAsyncRepository<T,​ID>

    public interface AsyncCrudRepository<T,​ID>
    extends org.springframework.data.repository.Repository<T,​ID>
    Asynchronous version of CrudRepository.
    Since:
    3.0
    Author:
    Ryan Lubke
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.Long> count()
      Returns the number of entities available.
      java.util.concurrent.CompletableFuture<java.lang.Void> delete​(T entity)
      Deletes a given entity.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteAll()
      Deletes all entities managed by the repository.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteAll​(java.lang.Iterable<? extends T> entities)
      Deletes the given entities.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteAllById​(java.lang.Iterable<? extends ID> ids)
      Deletes all instances of the type T with the given IDs.
      java.util.concurrent.CompletableFuture<java.lang.Void> deleteById​(ID id)
      Deletes the entity with the given id.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> existsById​(ID id)
      Returns whether an entity with the given id exists.
      java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> findAll()
      Returns all instances of the type.
      java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> findAllById​(java.lang.Iterable<ID> ids)
      Returns all instances of the type T with the given IDs.
      java.util.concurrent.CompletableFuture<java.util.Optional<T>> findById​(ID id)
      Retrieves an entity by its id.
      <S extends T>
      java.util.concurrent.CompletableFuture<S>
      save​(S entity)
      Saves a given entity.
      <S extends T>
      java.util.concurrent.CompletableFuture<java.lang.Iterable<S>>
      saveAll​(java.lang.Iterable<S> entities)
      Saves all given entities.
    • Method Detail

      • save

        <S extends T> java.util.concurrent.CompletableFuture<S> save​(S entity)
        Saves a given entity. Use the returned instance for further operations as the save operation might have changed the entity instance completely.
        Type Parameters:
        S - the entity type
        Parameters:
        entity - must not be null
        Returns:
        the saved entity; will never be null
        Throws:
        java.lang.IllegalArgumentException - in case the given entity is null
      • saveAll

        <S extends T> java.util.concurrent.CompletableFuture<java.lang.Iterable<S>> saveAll​(java.lang.Iterable<S> entities)
        Saves all given entities.
        Type Parameters:
        S - the entity type
        Parameters:
        entities - must not be null nor must it contain null
        Returns:
        the saved entities; will never be null. The returned Iterable will have the same size as the Iterable passed as an argument
        Throws:
        java.lang.IllegalArgumentException - in case the given entities or one of its entities is null
      • findById

        java.util.concurrent.CompletableFuture<java.util.Optional<T>> findById​(ID id)
        Retrieves an entity by its id.
        Parameters:
        id - must not be null
        Returns:
        the entity with the given id or Optional#empty() if none found
        Throws:
        java.lang.IllegalArgumentException - if id is null
      • existsById

        java.util.concurrent.CompletableFuture<java.lang.Boolean> existsById​(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:
        java.lang.IllegalArgumentException - if id is null
      • findAll

        java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> findAll()
        Returns all instances of the type.
        Returns:
        all entities
      • findAllById

        java.util.concurrent.CompletableFuture<java.lang.Iterable<T>> findAllById​(java.lang.Iterable<ID> ids)
        Returns all instances of the type 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.

        Parameters:
        ids - must not be null nor contain any null values
        Returns:
        guaranteed to be not null. The size can be equal or less than the number of given ids
        Throws:
        java.lang.IllegalArgumentException - in case the given ids or one of its items is null
      • count

        java.util.concurrent.CompletableFuture<java.lang.Long> count()
        Returns the number of entities available.
        Returns:
        the number of entities
      • deleteById

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteById​(ID id)
        Deletes the entity with the given id.
        Parameters:
        id - must not be null
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        Throws:
        java.lang.IllegalArgumentException - in case the given id is null
      • delete

        java.util.concurrent.CompletableFuture<java.lang.Void> delete​(T entity)
        Deletes a given entity.
        Parameters:
        entity - must not be null
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        Throws:
        java.lang.IllegalArgumentException - in case the given entity is null
      • deleteAllById

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteAllById​(java.lang.Iterable<? extends ID> ids)
        Deletes all instances of the type T with the given IDs.
        Parameters:
        ids - must not be null. Must not contain null elements
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        Throws:
        java.lang.IllegalArgumentException - in case the given ids or one of its elements is null
      • deleteAll

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteAll​(java.lang.Iterable<? extends T> entities)
        Deletes the given entities.
        Parameters:
        entities - must not be null. Must not contain null elements
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed
        Throws:
        java.lang.IllegalArgumentException - in case the given entities or one of its entities is null
      • deleteAll

        java.util.concurrent.CompletableFuture<java.lang.Void> deleteAll()
        Deletes all entities managed by the repository.
        Returns:
        a CompletableFuture that can be used to determine whether the operation completed