Interface TopiaDao<E extends TopiaEntity>

All Superinterfaces:
Iterable<E>
All Known Implementing Classes:
AbstractTopiaDao

public interface TopiaDao<E extends TopiaEntity> extends Iterable<E>
This contract represents the common operations any Dao should be able to provide as API.
Since:
3.0
Author:
bleny
  • Method Details

    • getEntityClass

      Class<E> getEntityClass()
      Return the class of the entity managed by this DAO.
      Returns:
      this DAO's managed entity's class
    • getBatchSize

      int getBatchSize()
      Obtains the batch size used to load data. Default value if 1000.
      Returns:
      the batch size.
      Since:
      2.6.14
    • setBatchSize

      void setBatchSize(int batchSize)
      Set a new default batch size.
      Parameters:
      batchSize - new batch size to use when iterating.
      Since:
      2.6.14
    • newInstance

      E newInstance()
      Returns:
      instantiate of managed entity not persisted.
      Since:
      2.3.1
    • newInstance

      E newInstance(Map<String,Object> properties)
      Returns:
      instantiate of managed entity not persisted.
      Since:
      2.6
    • newInstance

      E newInstance(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues)
      Returns:
      instantiate of managed entity not persisted.
      Since:
      2.6
    • initPagination

      org.nuiton.util.pagination.PaginationResult<E> initPagination(int pageSize)
      Creates a new pager initialized for the first page of all data of the dao. Note: This method will execute a count query to init the pager.
      Parameters:
      pageSize - size of a page
      Returns:
      the initialized pager.
      Since:
      3.0
    • initPagination

      org.nuiton.util.pagination.PaginationResult<E> initPagination(String hql, Map<String,Object> params, int pageSize)
      Creates a new pager initialized for the first page of data of the given query. Note: This method will execute a count query to init the pager.
      Parameters:
      hql - query
      params - params of the query
      pageSize - size of a page
      Returns:
      the initialized pager.
      Since:
      3.0
    • create

      E create(E entity)
      Creates an entity not created without the DAO using any of the others create methods. The instance may have been created elsewhere.
      Parameters:
      entity - the instance to persist
      Returns:
      the persisted entity (with its topiaId valued)
      Since:
      2.3.1
    • create

      E create(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues)
      Parameters:
      propertyName - FIXME
      propertyValue - FIXME
      otherPropertyNamesAndValues - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • create

      E create(Map<String,Object> properties)
      Creates a new instance of the entity managed by the DAO
      Parameters:
      properties - the key-value list of properties that the created entity will have.
      Returns:
      the newly created entity
      Throws:
      IllegalArgumentException - if some property type is not the expected one
    • create

      E create()
      Returns:
      FIXME
      Since:
      3.0
    • update

      E update(E entity)
      Update an entity. May be used for an entity coming from another context.
      Parameters:
      entity - the entity to create or update
      Returns:
      the given entity
    • delete

      void delete(E entity)
      Deletes the given entity from the storage
      Parameters:
      entity - the entity to remove
    • deleteAll

      void deleteAll(Iterable<E> entities)
      Deletes all given entities from the storage
      Parameters:
      entities - entities to delete
      Since:
      3.0
    • findAll

      List<E> findAll()
      Finds all the entities managed by this DAO.
      Returns:
      the full list of entities in no particular (non-deterministic) order
    • streamAll

      Stream<E> streamAll()
      Stream all the entities managed by this DAO. Actual behavior rely on implementation: caller should BaseStream.close() the stream (may depend on implementation).
      Returns:
      the full list of entities in no particular (non-deterministic) order
    • findAllLazy

      Iterable<E> findAllLazy()
      Returns:
      FIXME
      Since:
      3.0
    • createAll

      Iterable<E> createAll(Iterable<E> entities)
      Parameters:
      entities - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • updateAll

      Iterable<E> updateAll(Iterable<E> entities)
      Parameters:
      entities - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • findAllIds

      List<String> findAllIds()
      Find all the ids for the entities managed by this DAO.
      Returns:
      the ids of all the entities
    • count

      long count()
      Count the number of existing entities.
      Returns:
      number of total entities
      Since:
      2.3.4
    • forAll

      Creates a QueryBuilder without restriction
      Returns:
      FIXME
      Since:
      3.0
    • forProperties

      Parameters:
      properties - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • forProperties

      TopiaQueryBuilderAddCriteriaOrRunQueryStep<E> forProperties(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues)
      Parameters:
      propertyName - FIXME
      propertyValue - FIXME
      otherPropertyNamesAndValues - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • newQueryBuilder

      default TopiaQueryBuilderAddCriteriaStep<E> newQueryBuilder()
      Returns:
      FIXME
      Since:
      3.0
    • newQueryBuilder

      TopiaQueryBuilderAddCriteriaStep<E> newQueryBuilder(FilterRuleGroupOperator filterRuleGroupOperator)
      Returns:
      FIXME
      Since:
      3.0
    • forContains

      TopiaQueryBuilderRunQueryStep<E> forContains(String propertyName, Object propertyValue)
      Parameters:
      propertyName - FIXME
      propertyValue - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • forEquals

      TopiaQueryBuilderRunQueryStep<E> forEquals(String propertyName, Object propertyValue)
      Parameters:
      propertyName - FIXME
      propertyValue - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • forIn

      TopiaQueryBuilderRunQueryStep<E> forIn(String propertyName, Collection<?> propertyValues)
      Parameters:
      propertyName - FIXME
      propertyValues - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • forTopiaIdEquals

      Parameters:
      topiaId - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • findByTopiaId

      @Deprecated E findByTopiaId(String topiaId) throws TopiaNoResultException
      Deprecated.
      Tries to find the entity with the given topiaId. If not found, an exception will be thrown. IMPORTANT : The behavior of the method changes in ToPIA 3.0 because an exception is thrown if no entity found.
      Parameters:
      topiaId - the identifier of the entity to look for
      Returns:
      The entity found
      Throws:
      TopiaNoResultException - if result is found, if you do not want an exception to be raised, use tryFindByTopiaId(String)
    • tryFindByTopiaId

      @Deprecated com.google.common.base.Optional<E> tryFindByTopiaId(String topiaId)
      Deprecated.
      Tries to find the entity with the given topiaId. If not found, the result.isPresent() will be false.
      Parameters:
      topiaId - the identifier of the entity to look for
      Returns:
      The entity found wrapped by an Optional
    • forTopiaIdIn

      Parameters:
      topiaIds - FIXME
      Returns:
      FIXME
      Since:
      3.0
    • addTopiaEntityListener

      void addTopiaEntityListener(TopiaEntityListener listener)
    • addTopiaEntityVetoable

      void addTopiaEntityVetoable(TopiaEntityVetoable vetoable)
    • removeTopiaEntityListener

      void removeTopiaEntityListener(TopiaEntityListener listener)
    • removeTopiaEntityVetoable

      void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable)
    • findUsages

      <R extends TopiaEntity> List<R> findUsages(Class<R> type, E entity)
      Find usages of the given entity in the entities of the given type.
      Type Parameters:
      R - type of entity to search
      Parameters:
      type - the type of entity to search
      entity - the entity on which search is done
      Returns:
      the list of entities R which uses the given entity
      Since:
      2.3.0
    • findAllUsages

      Map<Class<? extends TopiaEntity>,List<? extends TopiaEntity>> findAllUsages(E entity)
      Find all usages of the given entity.
      Parameters:
      entity - the entity
      Returns:
      the dictionnary of usages of the given entities (keys are entity usage container, values are the list of this type of entity to use the given entity).
      Since:
      2.3.0
    • getComposite

      List<TopiaEntity> getComposite(E entity)
      Parameters:
      entity - the entity on which search is done
      Returns:
      all objects that must be deleted if this object is deleted
      Since:
      3.0
    • getAggregate

      List<TopiaEntity> getAggregate(E entity)
      Parameters:
      entity - the entity on which search is done
      Returns:
      all objects that are aggregate with this instance, aggregate object are not removed automatically
      Since:
      3.0