Spring Data Commmons

org.springframework.data.repository
Interface Repository<T,ID extends Serializable>

All Known Subinterfaces:
PagingAndSortingRepository<T,ID>
All Known Implementing Classes:
RepositorySupport

public interface Repository<T,ID extends Serializable>

Interface for generic CRUD operations on a repository for a specific type.

Author:
Oliver Gierke, Eberhard Wolff

Method Summary
 Long count()
          Returns the number of entities available.
 void delete(Iterable<? extends T> entities)
          Deletes the given entities.
 void delete(T entity)
          Deletes a given entity.
 void deleteAll()
          Deletes all entities managed by the repository.
 boolean exists(ID id)
          Returns whether an entity with the given id exists.
 List<T> findAll()
          Returns all instances of the type.
 T findById(ID id)
          Retrives an entity by its primary key.
 List<T> save(Iterable<? extends T> entities)
          Saves all given entities.
 T save(T entity)
          Saves a given entity.
 

Method Detail

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 -
Returns:
the saved entity

save

List<T> save(Iterable<? extends T> entities)
Saves all given entities.

Parameters:
entities -
Returns:

findById

T findById(ID id)
Retrives an entity by its primary key.

Parameters:
id -
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 -
Returns:
true if an entity with the given id exists, alse otherwise
Throws:
IllegalArgumentException - if primaryKey is null

findAll

List<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(T entity)
Deletes a given entity.

Parameters:
entity -

delete

void delete(Iterable<? extends T> entities)
Deletes the given entities.

Parameters:
entities -

deleteAll

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


Spring Data Commmons

Copyright © 2011. All Rights Reserved.