Package tk.airshipcraft.commonlib.db
Interface GenericDao<T,ID>
- Type Parameters:
T
- the type of the model objectID
- the type of the model object's identifier
- All Known Subinterfaces:
AuthDataDao
,UserDao
,WarningDao
- All Known Implementing Classes:
SqlAuthDataDao
,SqlUserDao
,SqlWarningDao
public interface GenericDao<T,ID>
The GenericDao interface defines the standard CRUD operations to be performed on a model object.
This interface is generic and can be implemented for any type of model object.
-
Method Summary
Modifier and TypeMethodDescriptionCreates and saves a new entity.void
deleteById
(ID id) Deletes the entity with the given identifier.findAll()
Retrieves all entities of type T.Retrieves an entity by its identifier.Updates an existing entity.
-
Method Details
-
findById
Retrieves an entity by its identifier.- Parameters:
id
- the entity's identifier.- Returns:
- an Optional containing the found entity or an empty Optional if no entity is found.
-
findAll
Retrieves all entities of type T.- Returns:
- a list of all entities of type T.
-
create
Creates and saves a new entity.- Parameters:
entity
- the entity to be saved.- Returns:
- the saved entity, now persisted in the data store.
-
update
Updates an existing entity.- Parameters:
entity
- the entity to update.- Returns:
- the updated entity.
-
deleteById
Deletes the entity with the given identifier.- Parameters:
id
- the identifier of the entity to delete.
-