@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.OptimisticLockingFailureException
- when the entity uses optimistic locking and has a version attribute with
a different value from that found in the persistence store. Also thrown if the entity is assumed to be
present but does not exist in the database.<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.OptimisticLockingFailureException
- when at least one entity uses optimistic locking and has a version
attribute with a different value from that found in the persistence store. Also thrown if at least one
entity is assumed to be present but does not exist in the database.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)
If the entity is not found in the persistence store it is silently ignored.
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.OptimisticLockingFailureException
- when the entity uses optimistic locking and has a version attribute with
a different value from that found in the persistence store. Also thrown if the entity is assumed to be
present but does not exist in the database.void deleteAllById(Iterable<? extends ID> ids)
T
with the given IDs.
Entities that aren't found in the persistence store are silently ignored.
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.OptimisticLockingFailureException
- when at least one entity uses optimistic locking and has a version
attribute with a different value from that found in the persistence store. Also thrown if at least one
entity is assumed to be present but does not exist in the database.void deleteAll()
Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.