Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Spring Data Commons
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

All Superinterfaces:
  Repository<T,ID>

All Known Subinterfaces:
  PagingAndSortingRepository<T,ID>

    @NoRepositoryBean
    public interface CrudRepository<T,ID extends Serializable>

extends Repository<T,ID>

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(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` | `deleteAll()` Deletes all entities managed by the repository.
`boolean` | `exists(ID id)` Returns whether an entity with the given id exists.
`Iterable<T>` | `findAll()` Returns all instances of the type.
`T` | `findOne(ID id)` Retrives an entity by its primary key.
`Iterable<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

    Iterable<T> save(Iterable<? extends T> entities)

  Saves all given entities.

  Parameters:
    `entities` -
  Returns:

### findOne

    T findOne(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

    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` -

### 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Spring Data Commons
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2011. All Rights Reserved.