Interface BaseDao<T extends Identifiable>

Type Parameters:
T - type
All Known Subinterfaces:
AnalysisDao<T>, AnalysisResultSetDao<K,O>, AnnotationAssociationDao, ArrayDesignDao, AuditEventDao, AuditTrailDao, BaseVoEnabledDao<O,VO>, BibliographicReferenceDao, BioAssayDao, BioAssayDimensionDao, BioMaterialDao, BioSequenceDao, BlacklistedEntityDao, BlatAssociationDao, BlatResultDao, BrowsingDao<T>, CachedFilteringDao<O>, CachedFilteringVoEnabledDao<O,VO>, CharacteristicDao, ChromosomeDao, CoexpressionAnalysisDao, CoexpressionNodeDegreeDao, CompositeSequenceDao, CompoundDao, ContactDao, DatabaseEntryDao, DesignElementDataVectorDao<T>, DifferentialExpressionAnalysisDao, DifferentialExpressionResultDao, ExperimentalDesignDao, ExperimentalFactorDao, ExpressionAnalysisResultSetDao, ExpressionExperimentDao, ExpressionExperimentSetDao, ExpressionExperimentSubSetDao, ExternalDatabaseDao, FactorValueDao, FilteringDao<O>, FilteringVoEnabledDao<O,VO>, GeeqDao, Gene2GOAssociationDao, GeneAliasDao, GeneDao, GeneDiffExMetaAnalysisDao, GeneProductDao, GeneSetDao, PersonDao, PrincipalComponentAnalysisDao, ProcessedExpressionDataVectorDao, ProtocolDao, QuantitationTypeDao, RawAndProcessedExpressionDataVectorDao, RawExpressionDataVectorDao, ReferenceAssociationDao, StatementDao, TaxonDao, UnitDao, UserDao, UserGroupDao
All Known Implementing Classes:
AbstractCriteriaFilteringVoEnabledDao, AbstractCuratableDao, AbstractDao, AbstractDesignElementDataVectorDao, AbstractFilteringVoEnabledDao, AbstractNoopFilteringVoEnabledDao, AbstractQueryFilteringVoEnabledDao, AbstractVoEnabledDao, AnnotationAssociationDaoImpl, ArrayDesignDaoImpl, AuditEventDaoImpl, AuditTrailDaoImpl, BibliographicReferenceDaoImpl, BioAssayDaoImpl, BioAssayDimensionDaoImpl, BioMaterialDaoImpl, BioSequenceDaoImpl, BlacklistedEntityDaoImpl, BlatAssociationDaoImpl, BlatResultDaoImpl, CharacteristicDaoImpl, ChromosomeDaoImpl, CoexpressionAnalysisDaoImpl, CoexpressionNodeDegreeDaoImpl, CompositeSequenceDaoImpl, CompoundDaoImpl, ContactDaoImpl, DatabaseEntryDaoImpl, DifferentialExpressionResultDaoImpl, ExperimentalDesignDaoImpl, ExperimentalFactorDaoImpl, ExpressionAnalysisResultSetDaoImpl, ExpressionExperimentDaoImpl, ExpressionExperimentSetDaoImpl, ExpressionExperimentSubSetDaoImpl, ExternalDatabaseDaoImpl, FactorValueDaoImpl, GeeqDaoImpl, Gene2GOAssociationDaoImpl, GeneAliasDaoImpl, GeneDaoImpl, GeneDiffExMetaAnalysisDaoImpl, GeneProductDaoImpl, GeneSetDaoImpl, GeneSetMemberDaoImpl, PersonDaoImpl, PrincipalComponentAnalysisDaoImpl, ProcessedExpressionDataVectorDaoImpl, ProtocolDaoImpl, QuantitationTypeDaoImpl, RawAndProcessedExpressionDataVectorDaoImpl, RawExpressionDataVectorDaoImpl, ReferenceAssociationDaoImpl, StatementDaoImpl, TaxonDaoImpl, UnitDaoImpl, UserDaoImpl, UserGroupDaoImpl

public interface BaseDao<T extends Identifiable>
Interface that supports basic CRUD operations.
Author:
paul
  • Method Details

    • getElementClass

      Class<? extends T> getElementClass()
      Obtain the element class of BaseDao.
    • create

      Crates all the given entities in the persistent storage.
      Parameters:
      entities - the entities to be crated.
      Returns:
      collection of entities representing the instances in the persistent storage that were created.
    • create

      @CheckReturnValue T create(T entity)
      Create an object. If the entity type is immutable, this may also remove any existing entities identified by an appropriate 'find' method.
      Parameters:
      entity - the entity to create
      Returns:
      the persistent version of the entity
    • save

      Save all the given entities in the persistent storage.

      Unlike update(Collection), this method does not attach the given entities to the persistence context; the returned values must be used instead.

      See Also:
    • save

      @CheckReturnValue T save(T entity)
      Create or update an entity whether it is transient.

      Unlike update(Identifiable), this method does not attach the given entity to the persistence context and the returned value must be used instead.

      See Also:
    • load

      Collection<T> load(Collection<Long> ids)
      Loads entities with given ids form the persistent storage.
      Parameters:
      ids - the IDs of entities to be loaded. If some IDs are not found or null, they are skipped.
      Returns:
      collection of entities with given ids.
    • load

      @Nullable T load(Long id)
      Loads the entity with given id from the persistent storage.
      Parameters:
      id - the id of entity to load.
      Returns:
      the entity with given ID, or null if such entity does not exist or if the passed ID was null
      See Also:
    • loadAll

      Collection<T> loadAll()
      Loads all instanced of specific class from the persistent storage.
      Returns:
      a collection containing all instances that are currently accessible.
    • loadReference

      Collection<T> loadReference(Collection<Long> ids)
      Load references for all the given IDs.

      Entities already in the session will be returned directly.

    • loadReference

      @Nonnull T loadReference(Long id)
      Load reference for an entity.

      If the entity is already in the session, it will be returned instead. Note that unlike load(Long), this method will not return null if the entity does not exist.

      You may freely access the Identifiable.getId() field without triggering proxy initialization.

      See Also:
    • reload

      @Nonnull T reload(T entity) throws ObjectNotFoundException
      Reload an entity from the persistent storage.

      This does nothing if the entity is already in the session.

      Throws:
      ObjectNotFoundException - if the entity does not exist.
    • reload

      Reload an entity from the persistent storage.

      This does nothing for entities already in the session.

      Throws:
      ObjectNotFoundException
    • countAll

      long countAll()
      Counts all instances of specific class in the persistent storage.
      Returns:
      number that is the amount of instances currently accessible.
    • streamAll

      Stream<T> streamAll()
      Stream all instance of BaseDao from the persistent storage.
    • streamAll

      Stream<T> streamAll(boolean createNewSession)
      Stream all instances of BaseDao from the persistent storage.
      Parameters:
      createNewSession - whether to create a new session for the stream, it will be closed when the stream is closed
    • remove

      void remove(Collection<T> entities)
    • remove

      void remove(Long id)
      Remove a persistent instance based on its ID.

      The implementer is trusted to know what type of object to remove.

      Note that this method is to be avoided for Securable, because it will leave cruft in the ACL tables. We may fix this by having this method return the removed object.

      Parameters:
      id - the ID of the entity to be removed
    • remove

      void remove(T entity)
      Remove a persistent instance
      Parameters:
      entity - the entity to be removed
    • update

      void update(Collection<T> entities)
      Parameters:
      entities - Update the entities. Not supported if the entities are immutable.
    • update

      void update(T entity)
      Parameters:
      entity - Update the entity. Not supported if the entity is immutable.
    • find

      Does a look up for the given entity in the persistent storage, usually looking for a specific identifier ( either id or a string property).
      Parameters:
      entity - the entity to look for.
      Returns:
      an entity that was found in the persistent storage, or null if no such entity was found.
    • findOrCreate

      @CheckReturnValue T findOrCreate(T entity)
      Calls the find method, and if this method returns null, creates a new instance in the persistent storage.
      Parameters:
      entity - the entity to look for and persist if not found.
      Returns:
      the given entity, guaranteed to be representing an entity present in the persistent storage.