Interface IGeneralDAO<K extends java.io.Serializable,​B extends IGeneralBO<K>>

Type Parameters:
K - type of primary key
B - type of Business Object
All Known Subinterfaces:
ILongDAO<B>, IStringDAO<B>
All Known Implementing Classes:
AbstractBasicDAO, AbstractDAO, AbstractGeneralDAO, AbstractMemoryDao, AbstractPlainDAO

public interface IGeneralDAO<K extends java.io.Serializable,​B extends IGeneralBO<K>>
Interface for Data Access Objects.
Author:
ralph
  • Method Summary

    Modifier and Type Method Description
    void addDaoListener​(IDaoListener listener)
    Adds a DAO event listener.
    void clearCache()
    Clears the cache.
    void create​(B object)
    Inserts the object into the database if it does not exist.
    void create​(B object, boolean setCreationDate)
    Inserts the object into the database if it does not exist.
    void createObject​(java.lang.Object object)
    Inserts the object into the database if it does not exist.
    void createObject​(java.lang.Object object, boolean setCreationDate)
    Creates the object.
    void delete​(B object)
    Deletes the object.
    void delete​(java.util.Collection<B> objects)
    Deletes the objects.
    int deleteAll()
    Deletes all objects.
    void deleteByKey​(K id)
    Deletes the object of given key.
    void deleteByKeys​(java.util.Collection<K> ids)
    Deletes the objects.
    int deleteDefaultAll()
    Deletes all objects.
    void deleteObject​(java.lang.Object object)
    Deletes the object.
    java.util.List<B> findAll()
    Returns all domain objects.
    java.util.List<B> findAll​(int firstResult, int maxResults)
    Returns a subset of all objects.
    java.util.List<B> findAll​(int firstResult, int maxResults, java.lang.String sortBy)
    Returns a subset of all objects.
    java.util.List<B> findAll​(java.lang.String sortBy)
    Returns all domain objects.
    java.util.List<B> findBy​(java.util.Collection<K> ids)
    Find the given objects in model.
    java.util.List<B> findBy​(java.util.Collection<K> ids, java.lang.String sortBy)
    Find the given objects in model.
    B findBy​(K id)
    Find the given object in model.
    B findById​(java.lang.Object id)
    Find the given object in model.
    java.util.List<B> findDefaultAll()
    Returns domain objects with default criteria.
    java.util.List<B> findDefaultAll​(int firstResult, int maxResults)
    Returns domain objects with default criteria.
    java.util.List<B> findDefaultAll​(int firstResult, int maxResults, java.lang.String sortBy)
    Returns domain objects with default criteria.
    java.util.List<B> findDefaultAll​(java.lang.String sortBy)
    Returns domain objects with default criteria.
    IDaoMaster getDaoMaster()
    Returns the DAO master.
    int getDefaultObjectCount()
    Returns the number of objects with default criteria matched.
    IDaoFactory getFactory()
    Returns the DAO factory.
    int getObjectCount()
    Returns the number of domain objects.
    boolean isCacheEnabled()
    Returns status of caching mechanism.
    IDaoIterator<B> iterateAll()
    Returns all domain objects.
    IDaoIterator<B> iterateAll​(int firstResult, int maxResults)
    Returns a subset of all objects
    IDaoIterator<B> iterateAll​(int firstResult, int maxResults, java.lang.String sortBy)
    Returns a subset of all objects
    IDaoIterator<B> iterateAll​(java.lang.String sortBy)
    Returns all domain objects.
    IDaoIterator<B> iterateDefaultAll()
    Returns domain objects with default criteria.
    IDaoIterator<B> iterateDefaultAll​(int firstResult, int maxResults)
    Returns a subset of domain objects with default criteria.
    IDaoIterator<B> iterateDefaultAll​(int firstResult, int maxResults, java.lang.String sortBy)
    Returns a subset of domain objects with default criteria.
    IDaoIterator<B> iterateDefaultAll​(java.lang.String sortBy)
    Returns domain objects with default criteria.
    B newInstance()
    Create a new domain class instance.
    void refresh​(B object)
    Refresh the given object.
    void removeDaoListener​(IDaoListener listener)
    Removes a DAO event listener.
    void save​(B object)
    Saves the object.
    void save​(B object, boolean setChangeDate)
    Saves the object.
    void saveObject​(java.lang.Object object)
    Saves the object.
    void saveObject​(java.lang.Object object, boolean setChangeDate)
    Saves the object.
    void setCacheEnabled​(boolean enabled)
    Enables or disables the caching mechanism.
    void setDaoMaster​(IDaoMaster daoMaster)
    Sets the DAO master.
    void setFactory​(IDaoFactory factory)
    Sets the factory.
    void shutdown()
    Shutdown the DAO.
  • Method Details

    • getFactory

      IDaoFactory getFactory()
      Returns the DAO factory.
      Returns:
      the DAO factory this DAO is assigned to
    • setFactory

      void setFactory​(IDaoFactory factory)
      Sets the factory.
      Parameters:
      factory - - the factory this DAO belongs to
    • getDaoMaster

      IDaoMaster getDaoMaster()
      Returns the DAO master.
      Returns:
      the DAO master
    • setDaoMaster

      void setDaoMaster​(IDaoMaster daoMaster)
      Sets the DAO master.
      Parameters:
      daoMaster - the master
    • newInstance

      B newInstance()
      Create a new domain class instance. This method will set the creation date.
      Returns:
      new instance
    • shutdown

      void shutdown()
      Shutdown the DAO.
      Since:
      1.2.8
    • setCacheEnabled

      void setCacheEnabled​(boolean enabled)
      Enables or disables the caching mechanism.
      Parameters:
      enabled - true when cache shall be enabled.
    • isCacheEnabled

      boolean isCacheEnabled()
      Returns status of caching mechanism.
      Returns:
      true when cache shall be enabled.
    • createObject

      void createObject​(java.lang.Object object)
      Inserts the object into the database if it does not exist. This method will set the creation date.
      Parameters:
      object - domain class instance
    • createObject

      void createObject​(java.lang.Object object, boolean setCreationDate)
      Creates the object.
      Parameters:
      object - object to be saved
      setCreationDate - whether creationDate will be set
      See Also:
      create(IGeneralBO, boolean)
    • create

      void create​(B object)
      Inserts the object into the database if it does not exist. This method will set the creation date.
      Parameters:
      object - domain class instance
    • create

      void create​(B object, boolean setCreationDate)
      Inserts the object into the database if it does not exist.
      Parameters:
      object - domain class instance
      setCreationDate - whether creation date shall be set
    • getObjectCount

      int getObjectCount()
      Returns the number of domain objects.
      Returns:
      number of objects.
    • getDefaultObjectCount

      int getDefaultObjectCount()
      Returns the number of objects with default criteria matched. This method shall be used if you want to count only non-deleted objects.
      Returns:
      number of objects
    • findBy

      B findBy​(K id)
      Find the given object in model.
      Parameters:
      id - id of object
      Returns:
      object
    • findById

      B findById​(java.lang.Object id)
      Find the given object in model. This method is an alternative in case you cannot specify the type of ID at compile time.
      Parameters:
      id - id of object
      Returns:
      object
    • refresh

      void refresh​(B object)
      Refresh the given object.

      The method will throw an ObjectDeletedException when the underlying persistence store does not have this object anymore.

      Parameters:
      object - object to be refreshed
    • findBy

      java.util.List<B> findBy​(java.util.Collection<K> ids)
      Find the given objects in model.
      Parameters:
      ids - ids of objects
      Returns:
      object
    • findBy

      java.util.List<B> findBy​(java.util.Collection<K> ids, java.lang.String sortBy)
      Find the given objects in model.
      Parameters:
      ids - - ids of objects
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      object
    • findAll

      java.util.List<B> findAll()
      Returns all domain objects.
      Returns:
      list of all objects
    • findAll

      java.util.List<B> findAll​(java.lang.String sortBy)
      Returns all domain objects.
      Parameters:
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      list of all objects
      Since:
      1.3.2
    • findAll

      java.util.List<B> findAll​(int firstResult, int maxResults)
      Returns a subset of all objects.
      Parameters:
      firstResult - index of first result
      maxResults - maximum number of results to return
      Returns:
      list of objects
    • findAll

      java.util.List<B> findAll​(int firstResult, int maxResults, java.lang.String sortBy)
      Returns a subset of all objects.
      Parameters:
      firstResult - index of first result
      maxResults - maximum number of results to return
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      list of objects
      Since:
      1.3.2
    • findDefaultAll

      java.util.List<B> findDefaultAll()
      Returns domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects)
      Returns:
      list of all objects
    • findDefaultAll

      java.util.List<B> findDefaultAll​(java.lang.String sortBy)
      Returns domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects)
      Parameters:
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      list of all objects
      Since:
      1.3.2
    • findDefaultAll

      java.util.List<B> findDefaultAll​(int firstResult, int maxResults)
      Returns domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects).
      Parameters:
      firstResult - - the first result to be returned
      maxResults - - the number of results returned at most
      Returns:
      list of all objects
    • findDefaultAll

      java.util.List<B> findDefaultAll​(int firstResult, int maxResults, java.lang.String sortBy)
      Returns domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects).
      Parameters:
      firstResult - - the first result to be returned
      maxResults - - the number of results returned at most
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      list of all objects
      Since:
      1.3.2
    • iterateAll

      IDaoIterator<B> iterateAll()
      Returns all domain objects.
      Returns:
      list of all objects
    • iterateAll

      IDaoIterator<B> iterateAll​(java.lang.String sortBy)
      Returns all domain objects.
      Parameters:
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      list of all objects
      Since:
      1.3.2
    • iterateAll

      IDaoIterator<B> iterateAll​(int firstResult, int maxResults)
      Returns a subset of all objects
      Parameters:
      firstResult - index of first result
      maxResults - maximum number of results to return
      Returns:
      iterator of BO
    • iterateAll

      IDaoIterator<B> iterateAll​(int firstResult, int maxResults, java.lang.String sortBy)
      Returns a subset of all objects
      Parameters:
      firstResult - index of first result
      maxResults - maximum number of results to return
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      iterator of BO
      Since:
      1.3.2
    • iterateDefaultAll

      IDaoIterator<B> iterateDefaultAll()
      Returns domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects)
      Returns:
      list of all objects
    • iterateDefaultAll

      IDaoIterator<B> iterateDefaultAll​(java.lang.String sortBy)
      Returns domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects)
      Parameters:
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      list of all objects
      Since:
      1.3.2
    • iterateDefaultAll

      IDaoIterator<B> iterateDefaultAll​(int firstResult, int maxResults)
      Returns a subset of domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects)
      Parameters:
      firstResult - index of first result
      maxResults - maximum number of results to return
      Returns:
      list of all objects
    • iterateDefaultAll

      IDaoIterator<B> iterateDefaultAll​(int firstResult, int maxResults, java.lang.String sortBy)
      Returns a subset of domain objects with default criteria. A default criteria could hide objects not needed regulary (e.g. deleted objects)
      Parameters:
      firstResult - index of first result
      maxResults - maximum number of results to return
      sortBy - - the order clauses, e.g. column1 ASC, column2, column3 DESC
      Returns:
      list of all objects
      Since:
      1.3.2
    • saveObject

      void saveObject​(java.lang.Object object)
      Saves the object. This method assumes that the object already exists. Also, this method will set the change date.
      Parameters:
      object - object to be saved
    • saveObject

      void saveObject​(java.lang.Object object, boolean setChangeDate)
      Saves the object. This method assumes that the object already exists.
      Parameters:
      object - object to be saved
      setChangeDate - whether changeDate will be set
    • save

      void save​(B object)
      Saves the object. This method assumes that the object already exists. Also, this method will set the change date.
      Parameters:
      object - object to be saved
    • save

      void save​(B object, boolean setChangeDate)
      Saves the object. This method assumes that the object already exists.
      Parameters:
      object - object to be saved
      setChangeDate - whether changeDate will be set
    • deleteObject

      void deleteObject​(java.lang.Object object)
      Deletes the object.
      Parameters:
      object - object to be saved
    • delete

      void delete​(B object)
      Deletes the object. This method assumes that the object existed before.
      Parameters:
      object - object to be deleted.
    • delete

      void delete​(java.util.Collection<B> objects)
      Deletes the objects. This method assumes that the objects existed before.
      Parameters:
      objects - objects to be deleted.
    • deleteByKey

      void deleteByKey​(K id)
      Deletes the object of given key. This method assumes that the object existed before.
      Parameters:
      id - id of object to be deleted.
    • deleteByKeys

      void deleteByKeys​(java.util.Collection<K> ids)
      Deletes the objects. This method assumes that the object existed before.
      Parameters:
      ids - id of objects to be deleted.
    • deleteAll

      int deleteAll()
      Deletes all objects.
      Returns:
      number of object deleted
    • deleteDefaultAll

      int deleteDefaultAll()
      Deletes all objects.
      Returns:
      number of object deleted
    • addDaoListener

      void addDaoListener​(IDaoListener listener)
      Adds a DAO event listener.
      Parameters:
      listener - listener
    • removeDaoListener

      void removeDaoListener​(IDaoListener listener)
      Removes a DAO event listener.
      Parameters:
      listener - listener
    • clearCache

      void clearCache()
      Clears the cache.