Package dev.akif.crud

Interface CRUDRepository<I extends Serializable,E extends CRUDEntity<I,E>>

Type Parameters:
I - Id type of the data
E - Entity type of the data
All Superinterfaces:
org.springframework.data.repository.Repository<E,I>
All Known Subinterfaces:
SimpleRepository<I,E>, SimplerRepository<I,E>, SimplestRepository<I,E>

@NoRepositoryBean public interface CRUDRepository<I extends Serializable,E extends CRUDEntity<I,E>> extends org.springframework.data.repository.Repository<E,I>
Base interface of a CRUD repository for data layer

This is meant to be implemented from a @Repository interface.

  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.data.domain.Page<E>
    findAllByDeletedAtIsNull(org.springframework.data.domain.Pageable pageable)
    Finds all entities for given pagination and deletion flag
    Finds an entity with given id and deletion flag
    void
    Flushes changes made to the entities, meaning any change will be persisted.
    save(E entity)
    Saves given entity, used when creating a new entity
    int
    updateByVersion(E entity, int version)
    Updates given entity if it is at given version
  • Method Details

    • findAllByDeletedAtIsNull

      org.springframework.data.domain.Page<E> findAllByDeletedAtIsNull(org.springframework.data.domain.Pageable pageable)
      Finds all entities for given pagination and deletion flag
      Parameters:
      pageable - Pageable for the pagination
      Returns:
      Page of found entities
    • findByIdAndDeletedAtIsNull

      Optional<E> findByIdAndDeletedAtIsNull(I id)
      Finds an entity with given id and deletion flag
      Parameters:
      id - Id of the entity to find
      Returns:
      Found entity in an Optional
    • save

      @Modifying E save(E entity)
      Saves given entity, used when creating a new entity
      Parameters:
      entity - Entity to save
      Returns:
      Saved entity
    • updateByVersion

      @Modifying int updateByVersion(E entity, int version)
      Updates given entity if it is at given version
      Parameters:
      entity - Entity to save
      version - Expected version of the entity before the update
      Returns:
      Number of affected rows
    • flush

      void flush()
      Flushes changes made to the entities, meaning any change will be persisted.