Class AbstractTopiaDao<E extends TopiaEntity>
java.lang.Object
org.nuiton.topia.persistence.internal.AbstractTopiaDao<E>
- Type Parameters:
E- the managed entity type
This class has the common methods usable for each Dao managed by Topia. It is not JPA implementation dependent, it
only relies on TopiaJpaSupport.
This class is directly extended by the GeneratedXyzTopiaDao which groups all the Xyz specific methods.
Instances are created bt the model's specificTopiaPersistenceContext, which implements the
TopiaDaoSupplier contract.- Author:
- Benjamin Poussin - poussin@codelutin.com, Arnaud Thimel (Code Lutin), Tony Chemit - tchemit@codelutin.com
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstractTopiaDao.FindAllIterator<E extends TopiaEntity,O> static classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intDefault batch size used to iterate on data.protected static final com.google.common.base.Function<org.nuiton.util.pagination.PaginationOrder,String> protected TopiaDaoSupplierprotected TopiaFiresSupportprotected TopiaHibernateSupportprotected TopiaIdFactoryprotected TopiaJpaSupportprotected TopiaSqlSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTopiaEntityListener(TopiaEntityListener listener) voidaddTopiaEntityVetoable(TopiaEntityVetoable vetoable) longcount()Count the number of existing entities.protected longcreate()Creates an entity not created without the DAO using any of the others create methods.Creates a new instance of the entity managed by the DAOvoidDeletes the given entity from the storagevoidDeletes all given entities from the storageprotected booleanprotected <O> List<O>protected <O> List<O>protected <O> List<O>find(String hql, Map<String, Object> hqlParameters, org.nuiton.util.pagination.PaginationParameter page) findAll()Finds all the entities managed by this DAO.protected <O> List<O>protected <O> List<O>Find all the ids for the entities managed by this DAO.protected <O> Iterable<O>findAllLazy(String hql) protected <O> Iterable<O>findAllLazy(String hql, int batchSize) protected <O> Iterable<O>findAllLazy(String hql, Map<String, Object> hqlParameters) protected <O> Iterable<O>findAllLazy(String hql, Map<String, Object> hqlParameters, int batchSize) protected <O> Oprotected <O> OfindAnyOrNull(String hql) protected <O> OfindAnyOrNull(String hql, Map<String, Object> hqlParameters) findByTopiaId(String topiaId) Deprecated.protected <O> Oprotected <O> OfindFirstOrNull(String hql, Map<String, Object> hqlParameters) protected <O> org.nuiton.util.pagination.PaginationResult<O>findPage(String hql, Map<String, Object> hqlParameters, org.nuiton.util.pagination.PaginationParameter page) protected <O> OfindUnique(String hql, Map<String, Object> hqlParameters) protected <O> OfindUniqueOrNull(String hql, Map<String, Object> hqlParameters) forAll()Creates a QueryBuilder without restrictionforContains(String propertyName, Object propertyValue) forHql(String hql, String parameterName, Object parameterValue, Object... otherParameterNamesAndValues) forIn(String propertyName, Collection<?> propertyValues) forProperties(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) forProperties(Map<String, Object> properties) forTopiaIdEquals(String topiaId) forTopiaIdIn(Collection<String> topiaIds) intObtains the batch size used to load data.Return the class of the entity managed by this DAO.protected HqlAndParametersBuilder<E>protected HqlAndParametersBuilder<E>getHqlForProperties(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) protected HqlAndParametersBuilder<E>getHqlForProperties(Map<String, Object> properties) abstract TopiaEntityEnumprotected booleanhqlContainsCount(String hql) protected booleanhqlContainsOrderBy(String hql) protected booleanvoidinit(TopiaJpaSupport topiaJpaSupport, TopiaHibernateSupport topiaHibernateSupport, TopiaSqlSupport topiaSqlSupport, TopiaIdFactory topiaIdFactory, TopiaFiresSupport topiaFiresSupport, TopiaDaoSupplier topiaDaoSupplier) When AbstractTopiaContext create the TopiaDAOHibernate, it must call this method just after.org.nuiton.util.pagination.PaginationResult<E>initPagination(int pageSize) Creates a new pager initialized for the first page of all data of the dao.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.iterator()protected Stringprotected StringnewFromClause(String alias) protected HqlAndParametersBuilder<E>protected HqlAndParametersBuilder<E>newHqlAndParametersBuilder(FilterRuleGroupOperator filterRuleGroupOperator) newInstance(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) newInstance(Map<String, Object> properties) newQueryBuilder(FilterRuleGroupOperator filterRuleGroupOperator) voidremoveTopiaEntityListener(TopiaEntityListener listener) voidremoveTopiaEntityVetoable(TopiaEntityVetoable vetoable) voidsetBatchSize(int batchSize) Set a new default batch size.protected <O> Stream<O>protected <O> Stream<O>Stream all the entities managed by this DAO.protected <O> com.google.common.base.Optional<O>tryFindAny(String hql, Map<String, Object> hqlParameters) com.google.common.base.Optional<E>tryFindByTopiaId(String topiaId) Deprecated.protected <O> com.google.common.base.Optional<O>tryFindFirst(String hql, Map<String, Object> hqlParameters) protected <O> com.google.common.base.Optional<O>tryFindUnique(String hql, Map<String, Object> hqlParameters) Update an entity.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.nuiton.topia.persistence.TopiaDao
findAllUsages, findUsages, getAggregate, getComposite
-
Field Details
-
PAGINATION_ORDER_TO_HQL
protected static final com.google.common.base.Function<org.nuiton.util.pagination.PaginationOrder,String> PAGINATION_ORDER_TO_HQL -
batchSize
protected int batchSizeDefault batch size used to iterate on data.- Since:
- 2.6.14
-
topiaJpaSupport
-
topiaHibernateSupport
-
topiaSqlSupport
-
topiaIdFactory
-
topiaFiresSupport
-
topiaDaoSupplier
-
-
Constructor Details
-
AbstractTopiaDao
public AbstractTopiaDao()
-
-
Method Details
-
getTopiaEntityEnum
-
getEntityClass
Description copied from interface:TopiaDaoReturn the class of the entity managed by this DAO.- Specified by:
getEntityClassin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- this DAO's managed entity's class
-
init
public void init(TopiaJpaSupport topiaJpaSupport, TopiaHibernateSupport topiaHibernateSupport, TopiaSqlSupport topiaSqlSupport, TopiaIdFactory topiaIdFactory, TopiaFiresSupport topiaFiresSupport, TopiaDaoSupplier topiaDaoSupplier) When AbstractTopiaContext create the TopiaDAOHibernate, it must call this method just after.- Parameters:
topiaJpaSupport- FIXMEtopiaHibernateSupport- FIXMEtopiaSqlSupport- FIXMEtopiaIdFactory- FIXMEtopiaFiresSupport- FIXMEtopiaDaoSupplier- FIXME
-
getTopiaFiresSupport
-
getBatchSize
public int getBatchSize()Description copied from interface:TopiaDaoObtains the batch size used to load data. Default value if 1000.- Specified by:
getBatchSizein interfaceTopiaDao<E extends TopiaEntity>- Returns:
- the batch size.
-
setBatchSize
public void setBatchSize(int batchSize) Description copied from interface:TopiaDaoSet a new default batch size.- Specified by:
setBatchSizein interfaceTopiaDao<E extends TopiaEntity>- Parameters:
batchSize- new batch size to use when iterating.
-
newFromClause
-
newFromClause
-
newInstance
- Specified by:
newInstancein interfaceTopiaDao<E extends TopiaEntity>- Returns:
- instantiate of managed entity not persisted.
-
newInstance
- Specified by:
newInstancein interfaceTopiaDao<E extends TopiaEntity>- Returns:
- instantiate of managed entity not persisted.
-
newInstance
public E newInstance(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) - Specified by:
newInstancein interfaceTopiaDao<E extends TopiaEntity>- Returns:
- instantiate of managed entity not persisted.
-
initPagination
Description copied from interface:TopiaDaoCreates 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.- Specified by:
initPaginationin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
pageSize- size of a page- Returns:
- the initialized pager.
-
initPagination
public org.nuiton.util.pagination.PaginationResult<E> initPagination(String hql, Map<String, Object> params, int pageSize) Description copied from interface:TopiaDaoCreates 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.- Specified by:
initPaginationin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
hql- queryparams- params of the querypageSize- size of a page- Returns:
- the initialized pager.
-
addTopiaEntityListener
- Specified by:
addTopiaEntityListenerin interfaceTopiaDao<E extends TopiaEntity>
-
addTopiaEntityVetoable
- Specified by:
addTopiaEntityVetoablein interfaceTopiaDao<E extends TopiaEntity>
-
removeTopiaEntityListener
- Specified by:
removeTopiaEntityListenerin interfaceTopiaDao<E extends TopiaEntity>
-
removeTopiaEntityVetoable
- Specified by:
removeTopiaEntityVetoablein interfaceTopiaDao<E extends TopiaEntity>
-
create
Description copied from interface:TopiaDaoCreates an entity not created without the DAO using any of the others create methods. The instance may have been created elsewhere.- Specified by:
createin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
entity- the instance to persist- Returns:
- the persisted entity (with its topiaId valued)
-
create
- Specified by:
createin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
propertyName- FIXMEpropertyValue- FIXMEotherPropertyNamesAndValues- FIXME- Returns:
- FIXME
-
create
Description copied from interface:TopiaDaoCreates a new instance of the entity managed by the DAO- Specified by:
createin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
properties- the key-value list of properties that the created entity will have.- Returns:
- the newly created entity
-
create
- Specified by:
createin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- FIXME
-
createAll
- Specified by:
createAllin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
entities- FIXME- Returns:
- FIXME
-
update
Description copied from interface:TopiaDaoUpdate an entity. May be used for an entity coming from another context.- Specified by:
updatein interfaceTopiaDao<E extends TopiaEntity>- Parameters:
entity- the entity to create or update- Returns:
- the given entity
-
updateAll
- Specified by:
updateAllin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
entities- FIXME- Returns:
- FIXME
-
delete
Description copied from interface:TopiaDaoDeletes the given entity from the storage- Specified by:
deletein interfaceTopiaDao<E extends TopiaEntity>- Parameters:
entity- the entity to remove
-
deleteAll
Description copied from interface:TopiaDaoDeletes all given entities from the storage- Specified by:
deleteAllin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
entities- entities to delete
-
newHqlAndParametersBuilder
protected HqlAndParametersBuilder<E> newHqlAndParametersBuilder(FilterRuleGroupOperator filterRuleGroupOperator) -
newHqlAndParametersBuilder
-
getHqlForProperties
protected HqlAndParametersBuilder<E> getHqlForProperties(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) -
getHqlForNoConstraint
-
getHqlForProperties
-
forHql
-
forHql
-
forHql
-
forAll
Description copied from interface:TopiaDaoCreates a QueryBuilder without restriction- Specified by:
forAllin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- FIXME
-
forProperties
public AbstractTopiaDao.InnerTopiaQueryBuilderAddCriteriaOrRunQueryStep<E> forProperties(Map<String, Object> properties) - Specified by:
forPropertiesin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
properties- FIXME- Returns:
- FIXME
-
forProperties
public AbstractTopiaDao.InnerTopiaQueryBuilderAddCriteriaOrRunQueryStep<E> forProperties(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) - Specified by:
forPropertiesin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
propertyName- FIXMEpropertyValue- FIXMEotherPropertyNamesAndValues- FIXME- Returns:
- FIXME
-
newQueryBuilder
- Specified by:
newQueryBuilderin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- FIXME
-
newQueryBuilder
public AbstractTopiaDao.InnerTopiaQueryBuilderAddCriteriaOrRunQueryStep<E> newQueryBuilder(FilterRuleGroupOperator filterRuleGroupOperator) - Specified by:
newQueryBuilderin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- FIXME
-
forContains
public TopiaQueryBuilderAddCriteriaOrRunQueryStep<E> forContains(String propertyName, Object propertyValue) - Specified by:
forContainsin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
propertyName- FIXMEpropertyValue- FIXME- Returns:
- FIXME
-
forEquals
public TopiaQueryBuilderAddCriteriaOrRunQueryStep<E> forEquals(String propertyName, Object propertyValue) - Specified by:
forEqualsin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
propertyName- FIXMEpropertyValue- FIXME- Returns:
- FIXME
-
forIn
public TopiaQueryBuilderAddCriteriaOrRunQueryStep<E> forIn(String propertyName, Collection<?> propertyValues) - Specified by:
forInin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
propertyName- FIXMEpropertyValues- FIXME- Returns:
- FIXME
-
exists
-
count
-
findUnique
protected <O> O findUnique(String hql, Map<String, Object> hqlParameters) throws TopiaNoResultException, TopiaNonUniqueResultException -
tryFindUnique
protected <O> com.google.common.base.Optional<O> tryFindUnique(String hql, Map<String, Object> hqlParameters) throws TopiaNonUniqueResultException- Throws:
TopiaNonUniqueResultException
-
findUniqueOrNull
protected <O> O findUniqueOrNull(String hql, Map<String, Object> hqlParameters) throws TopiaNonUniqueResultException- Throws:
TopiaNonUniqueResultException
-
findFirst
protected <O> O findFirst(String hql, Map<String, Object> hqlParameters) throws QueryMissingOrderException- Throws:
QueryMissingOrderException
-
tryFindFirst
protected <O> com.google.common.base.Optional<O> tryFindFirst(String hql, Map<String, Object> hqlParameters) throws QueryMissingOrderException- Throws:
QueryMissingOrderException
-
findFirstOrNull
protected <O> O findFirstOrNull(String hql, Map<String, Object> hqlParameters) throws QueryMissingOrderException- Throws:
QueryMissingOrderException
-
findAny
- Throws:
TopiaNoResultException
-
tryFindAny
-
findAnyOrNull
-
findAnyOrNull
-
findAll
-
findAll
-
stream
-
stream
-
find
-
find
-
find
-
findPage
-
findAllLazy
-
findAllLazy
-
findAllLazy
-
findAllLazy
-
forTopiaIdEquals
- Specified by:
forTopiaIdEqualsin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
topiaId- FIXME- Returns:
- FIXME
-
forTopiaIdIn
- Specified by:
forTopiaIdInin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
topiaIds- FIXME- Returns:
- FIXME
-
findByTopiaId
Deprecated.Description copied from interface:TopiaDaoTries 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.- Specified by:
findByTopiaIdin interfaceTopiaDao<E extends TopiaEntity>- 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, useTopiaDao.tryFindByTopiaId(String)
-
tryFindByTopiaId
Deprecated.Description copied from interface:TopiaDaoTries to find the entity with the given topiaId. If not found, the result.isPresent() will befalse.- Specified by:
tryFindByTopiaIdin interfaceTopiaDao<E extends TopiaEntity>- Parameters:
topiaId- the identifier of the entity to look for- Returns:
- The entity found wrapped by an Optional
-
findAllIds
Description copied from interface:TopiaDaoFind all the ids for the entities managed by this DAO.- Specified by:
findAllIdsin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- the ids of all the entities
-
findAll
Description copied from interface:TopiaDaoFinds all the entities managed by this DAO.- Specified by:
findAllin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- the full list of entities in no particular (non-deterministic) order
-
streamAll
Description copied from interface:TopiaDaoStream all the entities managed by this DAO. Actual behavior rely on implementation: caller shouldBaseStream.close()the stream (may depend on implementation).- Specified by:
streamAllin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- the full list of entities in no particular (non-deterministic) order
-
findAllLazy
- Specified by:
findAllLazyin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- FIXME
-
iterator
- Specified by:
iteratorin interfaceIterable<E extends TopiaEntity>
-
count
public long count()Description copied from interface:TopiaDaoCount the number of existing entities.- Specified by:
countin interfaceTopiaDao<E extends TopiaEntity>- Returns:
- number of total entities
-
hqlContainsOrderBy
-
hqlStartsWithSelect
-
hqlContainsCount
-