Interface CrudRepository<E,ID>
- Type Parameters:
E- The entity typeID- The ID type
- All Superinterfaces:
GenericRepository<E,ID>
- All Known Subinterfaces:
AccountRecordRepository, AccountRepository, ArraysEntityRepository, AuthorRepository, AuthorRepository, BasicTypesRepository, BasicTypesRepository, BookEntityRepository, BookRepository, CarRepository, CatalogRepository, CategoryRepository, CitizenRepository, CityRepository, CompanyRepository, CountryRepository, CountryRepository, DocumentRepository, DomainEventsRepository, DomainEventsRepository, EntityWithIdClass2Repository, EntityWithIdClassRepository, FaceRepository, FoodRepository, GenreRepository, HouseEntityRepository, JpaRepository<E,ID>, JsonEntityRepository, MealRepository, MultiArrayEntityRepository, NoseRepository, OrderRepository, PageableRepository<E, ID>, PatientRepository, PersonRepository, PersonRepository, ProductRepository, ProjectRepository, RegionRepository, RestaurantRepository, RestaurantRepository, RoleRepository, SaleItemRepository, SaleRepository, SaleRepository, SettlementRepository, SettlementTypeRepository, ShipmentRepository, StreamingPersonRepository, StudentRepository, StudentRepository, TimezoneBasicTypesRepository, UserRepository, UuidRepository, ZoneRepository
- All Known Implementing Classes:
BookRepository, BookRepository
A repository interface for performing CRUD (Create, Read, Update, Delete). This is a blocking
variant and is largely based on the same interface in Spring Data, however includes integrated validation support.
- Since:
- 1.0
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescriptionlongcount()Returns the number of entities available.voidDeletes a given entity.voidDeletes all entities managed by the repository.voidDeletes the given entities.voiddeleteById(ID id) Deletes the entity with the given id.booleanexistsById(ID id) Returns whether an entity with the given id exists.findAll()Returns all instances of the type.Retrieves an entity by its id.<S extends E>
Ssave(S entity) Saves the given valid entity, returning a possibly new entity representing the saved state.Saves all given entities, possibly returning new instances representing the saved state.<S extends E>
Supdate(S entity) This method issues an explicit update for the given entity.This method issues an explicit update for the given entities.
-
Method Details
-
save
Saves the given valid entity, returning a possibly new entity representing the saved state. Note that certain implementations may not be able to detect whether a save or update should be performed and may always perform an insert. Theupdate(Object)method can be used in this case to explicitly request an update.- Type Parameters:
S- The generic type- Parameters:
entity- The entity to save. Must not be null.- Returns:
- The saved entity will never be null.
-
update
This method issues an explicit update for the given entity. The method differs fromsave(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.- Type Parameters:
S- The generic type- Parameters:
entity- The entity to save. Must not be null.- Returns:
- The updated entity will never be null.
-
updateAll
This method issues an explicit update for the given entities. The method differs fromsaveAll(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.- Type Parameters:
S- The generic type- Parameters:
entities- The entities to update. Must not be null.- Returns:
- The updated entities will never be null.
-
saveAll
-
findById
-
existsById
Returns whether an entity with the given id exists.- Parameters:
id- must not be null.- Returns:
- true if an entity with the given id exists, false otherwise.
-
findAll
-
count
long count()Returns the number of entities available.- Returns:
- the number of entities
-
deleteById
-
delete
-
deleteAll
-
deleteAll
void deleteAll()Deletes all entities managed by the repository.
-