Interface DaoCrudMixin

All Known Implementing Classes:
AEventRunnerTest, AWorkflowEngineTest

public interface DaoCrudMixin
Mixin to simplify CRUD (create-read-update-delete) operations on entities implemented via the DaoProvider layer .
Since:
8.0.0
Author:
XIMA MEDIA GmbH
  • Method Summary

    Modifier and Type
    Method
    Description
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    T
    create(T entity)
    Creates the given non-persisted entity.
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    T
    createOrUpdate(T entity)
    Creates the given entity if not yet persisted, or updates it otherwise.
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    IGenericDao<T>
    dao(Class<T> entity)
     
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    IGenericDao<T>
    dao(T entity)
     
    default void
    delete(de.xima.cmn.dao.interfaces.IEntity<Long> entity)
    Delete the given entity.
    ec()
     
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    T
    read(Class<T> type, long id)
    Read the entity with the given database ID.
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    T
    read(Class<T> type, de.xima.cmn.criteria.FilterCriterion filters)
    Reads the entity with the given filter.
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    List<T>
    readAll(Class<T> type, de.xima.cmn.criteria.FilterCriterion filters)
    Reads the entity with the given filter.
    default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
    T
    update(T entity)
    Update the given existing entity.
  • Method Details

    • create

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> T create(T entity)
      Creates the given non-persisted entity.
      Type Parameters:
      T - Type of the entity.
      Parameters:
      entity - Entity to create.
      Returns:
      The created entity.
    • createOrUpdate

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> T createOrUpdate(T entity)
      Creates the given entity if not yet persisted, or updates it otherwise.
      Type Parameters:
      T - Type of the entity.
      Parameters:
      entity - Entity to create or update.
      Returns:
      The created or updated entity.
    • dao

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> IGenericDao<T> dao(Class<T> entity)
      Type Parameters:
      T - Type of the entity.
      Parameters:
      entity - An entity.
      Returns:
      A generic DAO for the given entity.
    • dao

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> IGenericDao<T> dao(T entity)
      Type Parameters:
      T - Type of the entity.
      Parameters:
      entity - Runtime type of the entity.
      Returns:
      A generic DAO for the given entity type.
    • delete

      default void delete(de.xima.cmn.dao.interfaces.IEntity<Long> entity)
      Delete the given entity.
      Parameters:
      entity - Entity to delete.
    • ec

      Returns:
      The entity context to use for database operations.
    • read

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> T read(Class<T> type, de.xima.cmn.criteria.FilterCriterion filters)
      Reads the entity with the given filter.
      Type Parameters:
      T - Type of the entity.
      Parameters:
      type - Type of the entity to read.
      filters - Filters to apply to the search for the entity.
      Returns:
      The single entity matching the given filter, or null if no entity matches.
      Throws:
      IllegalStateException - When more than one entity matches the given filters.
      See Also:
      • FilterCriterionBuilder, for creating complex filters.
    • read

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> T read(Class<T> type, long id)
      Read the entity with the given database ID.
      Type Parameters:
      T - Type of the entity.
      Parameters:
      type - Type of the entity to read.
      id - ID of the entity.
      Returns:
      The read entity, or null if no such entity exists.
    • readAll

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> List<T> readAll(Class<T> type, de.xima.cmn.criteria.FilterCriterion filters)
      Reads the entity with the given filter.
      Type Parameters:
      T - Type of the entity.
      Parameters:
      type - Type of the entity to read.
      filters - Filters to apply to the search for the entity.
      Returns:
      A list of all entities matching the given filter.
      See Also:
      • FilterCriterionBuilder, for creating complex filters.
    • update

      default <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> T update(T entity)
      Update the given existing entity.
      Type Parameters:
      T - Type of the entity.
      Parameters:
      entity - Entity to update.
      Returns:
      The updated entity.