Interface GenericDao<T,ID>

Type Parameters:
T - the type of the model object
ID - 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 Type
    Method
    Description
    create(T entity)
    Creates and saves a new entity.
    void
    Deletes the entity with the given identifier.
    Retrieves all entities of type T.
    Retrieves an entity by its identifier.
    update(T entity)
    Updates an existing entity.
  • Method Details

    • findById

      Optional<T> findById(ID id)
      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

      List<T> findAll()
      Retrieves all entities of type T.
      Returns:
      a list of all entities of type T.
    • create

      T create(T entity)
      Creates and saves a new entity.
      Parameters:
      entity - the entity to be saved.
      Returns:
      the saved entity, now persisted in the data store.
    • update

      T update(T entity)
      Updates an existing entity.
      Parameters:
      entity - the entity to update.
      Returns:
      the updated entity.
    • deleteById

      void deleteById(ID id)
      Deletes the entity with the given identifier.
      Parameters:
      id - the identifier of the entity to delete.