Package org.nuiton.topia.persistence
Interface TopiaDao<E extends TopiaEntity>
- All Superinterfaces:
Iterable<E>
- All Known Implementing Classes:
AbstractTopiaDao
This contract represents the common operations any Dao should be able to provide as API.
- Since:
- 3.0
- Author:
- bleny
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddTopiaEntityListener(TopiaEntityListener listener) voidaddTopiaEntityVetoable(TopiaEntityVetoable vetoable) longcount()Count the number of existing entities.create()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 storagefindAll()Finds all the entities managed by this DAO.Find all the ids for the entities managed by this DAO.Map<Class<? extends TopiaEntity>,List<? extends TopiaEntity>> findAllUsages(E entity) Find all usages of the givenentity.findByTopiaId(String topiaId) Deprecated.<R extends TopiaEntity>
List<R>findUsages(Class<R> type, E entity) Find usages of the givenentityin the entities of the giventype.forAll()Creates a QueryBuilder without restrictionforContains(String propertyName, Object propertyValue) forIn(String propertyName, Collection<?> propertyValues) forProperties(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) forProperties(Map<String, Object> properties) forTopiaIdEquals(String topiaId) forTopiaIdIn(Collection<String> topiaIds) getAggregate(E entity) intObtains the batch size used to load data.getComposite(E entity) Return the class of the entity managed by this DAO.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.newInstance(String propertyName, Object propertyValue, Object... otherPropertyNamesAndValues) newInstance(Map<String, Object> properties) default TopiaQueryBuilderAddCriteriaStep<E>newQueryBuilder(FilterRuleGroupOperator filterRuleGroupOperator) voidremoveTopiaEntityListener(TopiaEntityListener listener) voidremoveTopiaEntityVetoable(TopiaEntityVetoable vetoable) voidsetBatchSize(int batchSize) Set a new default batch size.Stream all the entities managed by this DAO.com.google.common.base.Optional<E>tryFindByTopiaId(String topiaId) Deprecated.Update an entity.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
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
- Returns:
- instantiate of managed entity not persisted.
- Since:
- 2.6
-
newInstance
- Returns:
- instantiate of managed entity not persisted.
- Since:
- 2.6
-
initPagination
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- queryparams- params of the querypageSize- size of a page- Returns:
- the initialized pager.
- Since:
- 3.0
-
create
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
- Parameters:
propertyName- FIXMEpropertyValue- FIXMEotherPropertyNamesAndValues- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
create
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
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
Deletes the given entity from the storage- Parameters:
entity- the entity to remove
-
deleteAll
Deletes all given entities from the storage- Parameters:
entities- entities to delete- Since:
- 3.0
-
findAll
Finds all the entities managed by this DAO.- Returns:
- the full list of entities in no particular (non-deterministic) order
-
streamAll
Stream all the entities managed by this DAO. Actual behavior rely on implementation: caller shouldBaseStream.close()the stream (may depend on implementation).- Returns:
- the full list of entities in no particular (non-deterministic) order
-
findAllLazy
- Returns:
- FIXME
- Since:
- 3.0
-
createAll
- Parameters:
entities- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
updateAll
- Parameters:
entities- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
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
TopiaQueryBuilderAddCriteriaOrRunQueryStep<E> 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- FIXMEpropertyValue- FIXMEotherPropertyNamesAndValues- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
newQueryBuilder
- Returns:
- FIXME
- Since:
- 3.0
-
newQueryBuilder
TopiaQueryBuilderAddCriteriaStep<E> newQueryBuilder(FilterRuleGroupOperator filterRuleGroupOperator) - Returns:
- FIXME
- Since:
- 3.0
-
forContains
- Parameters:
propertyName- FIXMEpropertyValue- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
forEquals
- Parameters:
propertyName- FIXMEpropertyValue- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
forIn
- Parameters:
propertyName- FIXMEpropertyValues- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
forTopiaIdEquals
- Parameters:
topiaId- FIXME- Returns:
- FIXME
- Since:
- 3.0
-
findByTopiaId
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, usetryFindByTopiaId(String)
-
tryFindByTopiaId
Deprecated.Tries to find the entity with the given topiaId. If not found, the result.isPresent() will befalse.- 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
-
addTopiaEntityVetoable
-
removeTopiaEntityListener
-
removeTopiaEntityVetoable
-
findUsages
Find usages of the givenentityin the entities of the giventype.- Type Parameters:
R- type of entity to search- Parameters:
type- the type of entity to searchentity- the entity on which search is done- Returns:
- the list of entities R which uses the given entity
- Since:
- 2.3.0
-
findAllUsages
Find all usages of the givenentity.- 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
- 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
- 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
-
forTopiaIdEquals(String)