Class AbstractDao<T extends Identifiable>
- All Implemented Interfaces:
BaseDao<T>
- Direct Known Subclasses:
AbstractDesignElementDataVectorDao, AbstractVoEnabledDao, AnnotationAssociationDaoImpl, AnnotationRelationDaoImpl, AnnotationSetDaoImpl, AnnotationSetDispositionDaoImpl, AnnotationSetTriageDaoImpl, AuditEventDaoImpl, AuditTrailDaoImpl, BlatAssociationDaoImpl, ChromosomeDaoImpl, CompoundDaoImpl, ContactDaoImpl, CurationDecisionDaoImpl, DifferentialExpressionResultDaoImpl, ExperimentalDesignDaoImpl, ExpressionExperimentSubSetDaoImpl, ExternalDatabaseDaoImpl, Gene2GOAssociationDaoImpl, GeneAliasDaoImpl, GeneDiffExMetaAnalysisDaoImpl, GeneSetDaoImpl, GeneSetMemberDaoImpl, PersonDaoImpl, PipelineJobBatchDaoImpl, PipelineJobDaoImpl, PipelineJobEventDaoImpl, PrincipalComponentAnalysisDaoImpl, ProtocolDaoImpl, PublicationAssociationDaoImpl, ReferenceAssociationDaoImpl, SingleCellDimensionExperimentDaoImpl, StatementDaoImpl, TicketDaoImpl, UnitDaoImpl, UserDaoImpl, UserGroupDaoImpl
SessionFactory.- Author:
- Anton, Nicolas
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDao(Class<? extends T> elementClass, SessionFactory sessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionlongcountAll()Counts all entities ofTin the persistent storage.create(Collection<T> entities) Create all the given entities in the persistent storage.Create an entity in the persistent storage.Does a look-up for the given entity in the persistent storage, usually looking for a specific identifier ifIdentifiable.getId()is set or a business key.findByProperty(String propertyName, Object propertyValue) findByPropertyIn(String propertyName, Collection<?> propertyValues) protected LongfindIdByProperty(String propertyName, Object propertyValue) protected TfindOneByProperty(String propertyName, Object propertyValue) findOrCreate(T entity) Calls theBaseDao.find(Identifiable)method, and if this method returns null, creates a new entity in the persistent storage pas perBaseDao.create(Identifiable).protected final intObtain the element class ofT.protected Stringprotected Stringprotected final SessionFactoryLoads the entity with given id from the persistent storage.load(Collection<Long> ids) Loads entities with given ids form the persistent storage.loadAll()Loads all entities of typeTfrom the persistent storage.loadReference(Long id) Load reference for an entity.loadReference(Collection<Long> ids) Load references of entities of typeTfor all the given IDs.reload(Collection<T> entities) Reload an entity from the persistent storage.Reload an entity from the persistent storage.voidremove(Collection<T> entities) Remove all given persistent entities.voidRemove a persistent entity.save(Collection<T> entities) Create (if transient) or update all the given entities in the persistent storage.Create (if transient) or update an entity.Stream all entities ofTfrom the persistent storage.streamAll(boolean createNewSession) Stream all entities of typeTfrom the persistent storage.protected <U> Stream<U> streamQuery(Function<Session, org.hibernate.query.Query<?>> queryCreator, Class<U> resultType, int fetchSize, boolean useCursorFetchIfSupported, boolean isStateless, boolean createNewSession) Produce a stream over aQuerywith a new session if desired.voidupdate(Collection<T> entities) Update the given entities.voidUpdate the given entity.
-
Field Details
-
log
protected final org.apache.commons.logging.Log log
-
-
Constructor Details
-
AbstractDao
-
-
Method Details
-
getElementClass
Description copied from interface:BaseDaoObtain the element class ofT.- Specified by:
getElementClassin interfaceBaseDao<T extends Identifiable>
-
getEntityName
-
getIdentifierPropertyName
-
create
Description copied from interface:BaseDaoCreate all the given entities in the persistent storage.- Specified by:
createin interfaceBaseDao<T extends Identifiable>- Parameters:
entities- the entities to be crated.- Returns:
- collection of entities representing the entities in the persistent storage that were created.
-
create
Description copied from interface:BaseDaoCreate an entity in the persistent storage.- Specified by:
createin interfaceBaseDao<T extends Identifiable>- Parameters:
entity- the entity to create- Returns:
- the persistent version of the entity
- See Also:
-
save
Description copied from interface:BaseDaoCreate (if transient) or update all the given entities in the persistent storage.Unlike
BaseDao.update(Collection), this method does not attach the given entities to the persistence context; the returned values must be used instead.- Specified by:
savein interfaceBaseDao<T extends Identifiable>- See Also:
-
save
Description copied from interface:BaseDaoCreate (if transient) or update an entity.Unlike
BaseDao.update(Identifiable), this method does not attach the given entity to the persistence context and the returned value must be used instead.- Specified by:
savein interfaceBaseDao<T extends Identifiable>- See Also:
-
load
Description copied from interface:BaseDaoLoads entities with given ids form the persistent storage.- Specified by:
loadin interfaceBaseDao<T extends Identifiable>- 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.
- See Also:
-
load
Description copied from interface:BaseDaoLoads the entity with given id from the persistent storage.- Specified by:
loadin interfaceBaseDao<T extends Identifiable>- 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
-
loadReference
Description copied from interface:BaseDaoLoad references of entities of typeTfor all the given IDs.Entities already in the current session will be returned directly.
- Specified by:
loadReferencein interfaceBaseDao<T extends Identifiable>
-
loadReference
Description copied from interface:BaseDaoLoad reference for an entity.If the entity is already in the session, it will be returned instead. Note that unlike
BaseDao.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.- Specified by:
loadReferencein interfaceBaseDao<T extends Identifiable>- See Also:
-
reload
-
reload
Description copied from interface:BaseDaoReload an entity from the persistent storage.This does nothing for entities already in the session.
- Specified by:
reloadin interfaceBaseDao<T extends Identifiable>
-
countAll
-
streamAll
Description copied from interface:BaseDaoStream all entities ofTfrom the persistent storage.Note that the stream will only be valid while the current database session is active. To create a stream that can outlive the current session, use
BaseDao.streamAll(boolean)passingtrue.- Specified by:
streamAllin interfaceBaseDao<T extends Identifiable>
-
streamAll
Description copied from interface:BaseDaoStream all entities of typeTfrom the persistent storage.If creating a new session, the caller is responsible for closing the stream to avoid resource leaks. It is recommended to use try-with-resource statement.
- Specified by:
streamAllin interfaceBaseDao<T extends Identifiable>- Parameters:
createNewSession- whether to create a new session for the stream, it will be closed when the stream is closed
-
streamQuery
-
remove
Description copied from interface:BaseDaoRemove all given persistent entities.- Specified by:
removein interfaceBaseDao<T extends Identifiable>
-
remove
-
update
Description copied from interface:BaseDaoUpdate the given entities.Not supported if the entity is immutable or loaded in read-only mode.
- Specified by:
updatein interfaceBaseDao<T extends Identifiable>
-
update
-
find
Description copied from interface:BaseDaoDoes a look-up for the given entity in the persistent storage, usually looking for a specific identifier ifIdentifiable.getId()is set or a business key.- Specified by:
findin interfaceBaseDao<T extends Identifiable>- 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
Description copied from interface:BaseDaoCalls theBaseDao.find(Identifiable)method, and if this method returns null, creates a new entity in the persistent storage pas perBaseDao.create(Identifiable).- Specified by:
findOrCreatein interfaceBaseDao<T extends Identifiable>- 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.
-
getSessionFactory
-
getBatchSize
protected final int getBatchSize() -
findOneByProperty
-
findIdByProperty
-
findByProperty
-
findByPropertyIn
-