Interface CrudRepository<T,ID extends Serializable>

All Known Subinterfaces:
AlfrescoRepository<T>
All Known Implementing Classes:
AlfrescoRepositoryImpl

public interface CrudRepository<T,ID extends Serializable>
Interface for generic CRUD operations on a repository for a specific type.
Version:
$Id: $Id
Author:
Oliver Gierke, Eberhard Wolff
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of entities available.
    void
    delete(ID id)
    Deletes the entity with the given id.
    void
    delete(Iterable<? extends T> entities)
    Deletes the given entities.
    void
    delete(T entity)
    Deletes a given entity.
    void
    Deletes all entities managed by the repository.
    boolean
    exists(ID id)
    Returns whether an entity with the given id exists.
    Returns all instances of the type.
    findOne(ID id)
    Retrives an entity by its primary key.
    save(Iterable<? extends T> entities)
    Saves all given entities.
    save(T entity)
    Saves a given entity.
  • Method Details

    • save

      T save(T entity)
      Saves a given entity. Use the returned instance for further operations as the save operation might have changed the entity instance completely.
      Parameters:
      entity - a T object.
      Returns:
      the saved entity
    • save

      Iterable<T> save(Iterable<? extends T> entities)
      Saves all given entities.
      Parameters:
      entities - a Iterable object.
      Returns:
      a Iterable object.
    • findOne

      T findOne(ID id)
      Retrives an entity by its primary key.
      Parameters:
      id - a ID object.
      Returns:
      the entity with the given primary key or null if none found
      Throws:
      IllegalArgumentException - if primaryKey is null
    • exists

      boolean exists(ID id)
      Returns whether an entity with the given id exists.
      Parameters:
      id - a ID object.
      Returns:
      true if an entity with the given id exists, alse otherwise
      Throws:
      IllegalArgumentException - if primaryKey is null
    • findAll

      Iterable<T> findAll()
      Returns all instances of the type.
      Returns:
      all entities
    • count

      long count()
      Returns the number of entities available.
      Returns:
      the number of entities
    • delete

      void delete(ID id)
      Deletes the entity with the given id.
      Parameters:
      id - a ID object.
    • delete

      void delete(T entity)
      Deletes a given entity.
      Parameters:
      entity - a T object.
    • delete

      void delete(Iterable<? extends T> entities)
      Deletes the given entities.
      Parameters:
      entities - a Iterable object.
    • deleteAll

      void deleteAll()
      Deletes all entities managed by the repository.