E
- The entity typeID
- The ID type@Validated public interface CrudRepository<E,ID> extends GenericRepository<E,ID>
Modifier and Type | Method and Description |
---|---|
long |
count()
Returns the number of entities available.
|
void |
delete(E entity)
Deletes a given entity.
|
void |
deleteAll()
Deletes all entities managed by the repository.
|
void |
deleteAll(@NotNull java.lang.Iterable<? extends E> entities)
Deletes the given entities.
|
void |
deleteById(ID id)
Deletes the entity with the given id.
|
boolean |
existsById(ID id)
Returns whether an entity with the given id exists.
|
java.lang.Iterable<E> |
findAll()
Returns all instances of the type.
|
java.util.Optional<E> |
findById(ID id)
Retrieves an entity by its id.
|
<S extends E> |
save(S entity)
Saves the given valid entity, returning a possibly new entity representing the saved state.
|
<S extends E> |
saveAll(@Valid @NotNull java.lang.Iterable<S> entities)
Saves all given entities, possibly returning new instances representing the saved state.
|
<S extends E> |
update(S entity)
This method issues an explicit update for the given entity.
|
<S extends E> |
updateAll(@Valid @NotNull java.lang.Iterable<S> entities)
This method issues an explicit update for the given entities.
|
@NonNull <S extends E> S save(@Valid @NotNull @NonNull S entity)
update(Object)
method can be used in this case to explicitly request an update.S
- The generic typeentity
- The entity to save. Must not be null.javax.validation.ConstraintViolationException
- if the entity is null or invalid.@NonNull <S extends E> S update(@Valid @NotNull @NonNull S entity)
save(Object)
in that an update will be generated regardless if the entity has been saved previously or not. If the entity has no assigned ID then an exception will be thrown.S
- The generic typeentity
- The entity to save. Must not be null.javax.validation.ConstraintViolationException
- if the entity is null or invalid.@NonNull <S extends E> java.lang.Iterable<S> updateAll(@Valid @NotNull @NonNull @Valid @NotNull java.lang.Iterable<S> entities)
saveAll(Iterable)
in that an update will be generated regardless if the entity has been saved previously or not. If the entity has no assigned ID then an exception will be thrown.S
- The generic typeentities
- The entities to update. Must not be null.javax.validation.ConstraintViolationException
- if entities is null or invalid.@NonNull <S extends E> java.lang.Iterable<S> saveAll(@Valid @NotNull @NonNull @Valid @NotNull java.lang.Iterable<S> entities)
S
- The generic typeentities
- The entities to saved. Must not be null.javax.validation.ConstraintViolationException
- if the entities are null.@NonNull java.util.Optional<E> findById(@NotNull @NonNull ID id)
id
- The ID of the entity to retrieve. Must not be null.javax.validation.ConstraintViolationException
- if the id is null.boolean existsById(@NotNull @NonNull ID id)
id
- must not be null.javax.validation.ConstraintViolationException
- if the id is null.@NonNull java.lang.Iterable<E> findAll()
long count()
void deleteById(@NonNull @NotNull ID id)
id
- must not be null.javax.validation.ConstraintViolationException
- if the entity is null.void delete(@NonNull @NotNull E entity)
entity
- The entity to deletejavax.validation.ConstraintViolationException
- if the entity is null.void deleteAll(@NonNull @NotNull @NotNull java.lang.Iterable<? extends E> entities)
entities
- The entities to deletejavax.validation.ConstraintViolationException
- if the entity is null.void deleteAll()