@NoRepositoryBean public interface CrudRepository<T,ID> extends Repository<T,ID>
Modifier and Type | Method and Description |
---|---|
long |
count()
Returns the number of entities available.
|
void |
delete(T entity)
Deletes a given entity.
|
void |
deleteAll()
Deletes all entities managed by the repository.
|
void |
deleteAll(Iterable<? extends T> entities)
Deletes the given entities.
|
void |
deleteAllById(Iterable<? extends ID> ids)
Deletes all instances of the type
T with the given IDs. |
void |
deleteById(ID id)
Deletes the entity with the given id.
|
boolean |
existsById(ID id)
Returns whether an entity with the given id exists.
|
Iterable<T> |
findAll()
Returns all instances of the type.
|
Iterable<T> |
findAllById(Iterable<ID> ids)
Returns all instances of the type
T with the given IDs. |
Optional<T> |
findById(ID id)
Retrieves an entity by its id.
|
<S extends T> |
save(S entity)
Saves a given entity.
|
<S extends T> |
saveAll(Iterable<S> entities)
Saves all given entities.
|
<S extends T> S save(S entity)
entity
- must not be null.IllegalArgumentException
- in case the given entity is null.<S extends T> Iterable<S> saveAll(Iterable<S> entities)
entities
- must not be null nor must it contain null.IllegalArgumentException
- in case the given entities
or one of its entities is
null.Optional<T> findById(ID id)
id
- must not be null.IllegalArgumentException
- if id is null.boolean existsById(ID id)
id
- must not be null.IllegalArgumentException
- if id is null.Iterable<T> findAllById(Iterable<ID> ids)
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.
ids
- must not be null nor contain any null values.IllegalArgumentException
- in case the given ids
or one of its items is null.long count()
void deleteById(ID id)
id
- must not be null.IllegalArgumentException
- in case the given id is nullvoid delete(T entity)
entity
- must not be null.IllegalArgumentException
- in case the given entity is null.void deleteAllById(Iterable<? extends ID> ids)
T
with the given IDs.ids
- must not be null. Must not contain null elements.IllegalArgumentException
- in case the given ids or one of its elements is null.void deleteAll(Iterable<? extends T> entities)
entities
- must not be null. Must not contain null elements.IllegalArgumentException
- in case the given entities or one of its entities is null.void deleteAll()
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.