Interface IGenericDAO<Entity extends Identifiable<ID> & Deletable,​ID extends Serializable>

  • Type Parameters:
    Entity - The entity type to which this generic dao presents an interface.
    ID - The identifier type of the Entity type.

    public interface IGenericDAO<Entity extends Identifiable<ID> & Deletable,​ID extends Serializable>
    This interface presents the common set of operations that any DAO should provide by default. Possible implementations of this interface are DAOs for JPA access or JDBC.
    Author:
    Paulo Zenida - Linkare TI
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int count()
      Provides the count operation for the list of entities found.
      void create​(Entity entity)
      Provides the create/persist operation for the entity passed in.
      Entity edit​(Entity entity)
      Provides the edit/merge operation for the entity passed in.
      List<Entity> find​(boolean all, int firstResult, int maxResults)
      Provides the find operation, allowing pagination of results.
      Entity find​(ID id)
      Provides the find operation, based on the entity's id.
      List<Entity> findAll()
      Provides the find all operation.
      List<Entity> findRange​(int[] range)
      Provides the find operation, according to a range of results.
      void remove​(Entity entity)
      Provides the remove operation for the entity passed in.
    • Method Detail

      • create

        void create​(Entity entity)
        Provides the create/persist operation for the entity passed in.
        Parameters:
        entity - the entity to create.
      • edit

        Entity edit​(Entity entity)
        Provides the edit/merge operation for the entity passed in.
        Parameters:
        entity - the entity to edit.
        Returns:
        Returns the entity after being merged/updated.
      • remove

        void remove​(Entity entity)
        Provides the remove operation for the entity passed in.
        Parameters:
        entity - the entity to remove.
      • find

        Entity find​(ID id)
        Provides the find operation, based on the entity's id.
        Parameters:
        id - the id to be found.
        Returns:
        Returns the entity if found. It returns null otherwise.
      • find

        List<Entity> find​(boolean all,
                          int firstResult,
                          int maxResults)
        Provides the find operation, allowing pagination of results.
        Parameters:
        all - flag to control if the method should look for all entities.
        firstResult - the number where the result query should start.
        maxResults - the maximum number of entities after firstResult that this method should return.
        Returns:
        Returns the list of entities found.
      • findRange

        List<Entity> findRange​(int[] range)
        Provides the find operation, according to a range of results.
        Parameters:
        range - the range to look for in the resulting list.
        Returns:
        Returns the list of entities found in the determined range.
      • findAll

        List<Entity> findAll()
        Provides the find all operation.
        Returns:
        Returns the full list of entities found.
      • count

        int count()
        Provides the count operation for the list of entities found.
        Returns:
        Returns the number of entities found.