Interface GenericDAO<T,PK extends Serializable>

Type Parameters:
T - the entity to save
PK - the primary key
All Superinterfaces:
Serializable
All Known Subinterfaces:
ConfigurationDAO
All Known Implementing Classes:
ConfigurationHbmDAO, GenericHbmDAO

@API(status=STABLE, since="1.0", consumers="GenrericHbmDAO") @Component public interface GenericDAO<T,PK extends Serializable> extends Serializable
GenericDAO primary for CRUD database operations. To use the DAO by your own configuration, you need to load the spring-dao.xml into your Spring context.
A detailed documentation can found at: https://github.com/ElmarDott/TP-CORE/wiki/%5BCORE-02%5D-generic-Data-Access-Object---DAO
Since:
1.0
Version:
1.4
Author:
elmar.dott@gmail.com
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Identifier for the given feature.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Count the entries of corresponding table to the domain object is specialized in the DAO.
    boolean
    create(T object)
    Persist a new entity and return TRUE if it was successful.In the case that the entity is already existing or the persist project is not a valid entity the method return FALSE.
    void
    delete(PK id)
    Search for an persistent entity.If it's already existent then it will be delete, otherwise a EntityNotFoundException will thrown.
    Tries to create from a collection of JSON objects a list of enties.
    Tried to create a entity object from a given JSON String.
    find(PK id)
    Try to find a persited domain object.
    Get the primary key of the DAO entity.
    Get all persited entries of an entity as list.
    Check if the entity is not NULL and try to create a JSON object as String, otherwise the String will be empty.
    void
    update(PK id, T object)
    Search an entity in the persistence context and update it.If it's not exist a EntityNotFoundException will thrown.
  • Field Details

    • FEATURE_ID

      @API(status=STABLE, since="1.2") static final String FEATURE_ID
      Identifier for the given feature.
      See Also:
  • Method Details

    • create

      @API(status=STABLE, since="1.0") boolean create(T object) throws DAOException
      Persist a new entity and return TRUE if it was successful.In the case that the entity is already existing or the persist project is not a valid entity the method return FALSE.
      Parameters:
      object - as Generic
      Returns:
      true on success
      Throws:
      DAOException
    • delete

      @API(status=STABLE, since="1.0") void delete(PK id) throws DAOException
      Search for an persistent entity.If it's already existent then it will be delete, otherwise a EntityNotFoundException will thrown.
      Parameters:
      id - as Generic
      Throws:
      DAOException
    • update

      @API(status=STABLE, since="1.0") void update(PK id, T object) throws DAOException
      Search an entity in the persistence context and update it.If it's not exist a EntityNotFoundException will thrown.
      Parameters:
      id - as Generic
      object - as Generic
      Throws:
      DAOException
    • countAllElements

      @API(status=STABLE, since="3.0") long countAllElements()
      Count the entries of corresponding table to the domain object is specialized in the DAO.
      Returns:
      count as long
    • listAllElements

      @API(status=STABLE, since="1.0") List<T> listAllElements(JpaPagination seekElement)
      Get all persited entries of an entity as list.
      Parameters:
      seekElement - as JpaPagination
      Returns:
      List of Entity Objects
    • getPrimaryKeyOfObject

      @API(status=STABLE, since="1.0") PK getPrimaryKeyOfObject(T object)
      Get the primary key of the DAO entity.
      Parameters:
      object - as Genric
      Returns:
      id as Genric
    • serializeAsJson

      @API(status=STABLE, since="1.0") String serializeAsJson(T object) throws JsonProcessingException
      Check if the entity is not NULL and try to create a JSON object as String, otherwise the String will be empty.
      Parameters:
      object - as Generic
      Returns:
      JSON object as String
      Throws:
      JsonProcessingException
      com.fasterxml.jackson.core.JsonProcessingException
    • deserializeJsonAsObject

      @API(status=STABLE, since="2.1") T deserializeJsonAsObject(String json, Class<T> object) throws JsonProcessingException, ClassNotFoundException
      Tried to create a entity object from a given JSON String.
      Parameters:
      json - as String
      object - as T
      Returns:
      Entity as Generic
      Throws:
      JsonProcessingException
      ClassNotFoundException
    • deserializeJsonAsList

      @API(status=STABLE, since="3.0") List<T> deserializeJsonAsList(String json) throws JsonProcessingException, ClassNotFoundException
      Tries to create from a collection of JSON objects a list of enties.
      Parameters:
      json - as String
      Returns:
      List of Entities
      Throws:
      JsonProcessingException
      ClassNotFoundException
    • find

      @API(status=STABLE, since="1.0") T find(PK id)
      Try to find a persited domain object.
      Parameters:
      id - as Generic
      Returns:
      object as Generic