- Type Parameters:
E
- the entity typeID
- the identifier type
- All Superinterfaces:
Data.GenericRepository<E,
ID>
- All Known Subinterfaces:
Data.CrudRepository<E,
ID>
- Enclosing class:
Data
Data repository interface for basic entity operations.
-
Method Summary
Modifier and TypeMethodDescriptionlong
count()
Return the number of all entities of theE
type.void
Delete provided entity.long
Delete all entities of theE
type.void
Delete all provided entities.long
deleteById
(ID id) Delete the entity with the given ID (primary key).boolean
existsById
(ID id) Check whether entity with given ID (primary key) exists.findAll()
Return all entities of theE
type.Find entity by ID (primary key) value.<T extends E>
Tsave
(T entity) Save provided entity.Save all provided entities.
-
Method Details
-
save
Save provided entity. This method will update existing record or insert a new record if record does not exist in the database.- Type Parameters:
T
- type of the entity- Parameters:
entity
- the entity to persist, shall not benull
- Returns:
- persisted entity. Never returns
null
- Throws:
DataException
- if the entity isnull
or the operation has failed
-
saveAll
Save all provided entities. This method will update existing record or insert a new record if record does not exist in the database.- Type Parameters:
T
- type of the entity- Parameters:
entities
- the entities to persist, shall not benull
- Returns:
- persisted entities, never returns
null
- Throws:
DataException
- if the entities arenull
or the operation has failed
-
findById
Find entity by ID (primary key) value.- Parameters:
id
- the ID of the entity to search for, shall not benull
- Returns:
- the entity with the given ID or
Optional#empty()
if no such entity was found, never returnsnull
- Throws:
DataException
- if the ID isnull
or the operation has failed
-
existsById
Check whether entity with given ID (primary key) exists.- Parameters:
id
- the ID of the entity to search for, shall not benull
- Returns:
- value of
true
if an entity with the given ID exists orfalse
otherwise - Throws:
DataException
- if the ID isnull
or the operation has failed
-
findAll
Return all entities of theE
type. This method will return all records from related database table, so it should be used carefully to avoid performance issues.- Returns:
- all entities found, never returns
null
- Throws:
DataException
- if the operation has failed
-
count
long count()Return the number of all entities of theE
type.- Returns:
- the number of all entities found
- Throws:
DataException
- if the operation has failed
-
deleteById
Delete the entity with the given ID (primary key).- Parameters:
id
- ID of the entity to be deleted, shall not benull
- Returns:
- the number of deleted entities
- Throws:
DataException
- if the ID isnull
or the operation has failed
-
delete
Delete provided entity.- Parameters:
entity
- the entity to delete, shall not benull
- Throws:
DataException
- if the entity isnull
or the operation has failed
-
deleteAll
Delete all provided entities.- Parameters:
entities
- the entities to delete, shall not benull
- Throws:
DataException
- if the entities arenull
or the operation has failed
-
deleteAll
long deleteAll()Delete all entities of theE
type. This method will delete all records from related database table, so it should be used carefully to avoid unexpected loss of data.- Returns:
- the number of deleted entities
- Throws:
DataException
- if the operation has failed
-