Package org.nuiton.topia.persistence
Interface TopiaDAO<E extends TopiaEntity>
- Type Parameters:
E- the entity type managed by the dao
- All Superinterfaces:
java.lang.Iterable<E>,TopiaDAODeprecated<E>
- All Known Implementing Classes:
TopiaDAOImpl,TopiaDAOLegacy
public interface TopiaDAO<E extends TopiaEntity> extends TopiaDAODeprecated<E>, java.lang.Iterable<E>
TopiaDAO is used to manipulate entities corresponding to
E type :
create, delete, update or find entities.
This interface is implemented by TopiaDAOImpl overridden by generation
from EntityDAOTransformer.- Version:
- $Id$
- Author:
- bpoussin <poussin@codelutin.com>, fdesbois <fdesbois@codelutin.com>, tchemit <chemit@codelutin.com>
-
Method Summary
Modifier and Type Method Description voidaddTopiaEntityListener(TopiaEntityListener listener)voidaddTopiaEntityVetoable(TopiaEntityVetoable vetoable)voidcomputeAndAddRecordsToPager(java.lang.String hql, TopiaPagerBean pager, java.lang.Object... params)Execute the counthqlquery and then synch the pager to this result (says fill thePagerBean.getRecords()field and then adapt the number of pages available and the current number page).longcount()Count the number of existing entities.longcountByQuery(java.lang.String hql, java.lang.Object... params)Count the number of entities based on ahql.Ecreate(E e)Permet de sauver un object instancié sans le DAO.Ecreate(java.lang.Object... properties)Construit une nouvelle instance de l'objet géré par ce DAOEcreate(java.util.Map<java.lang.String,java.lang.Object> properties)Construit une nouvelle instance de l'objet géré par ce DAOjava.lang.StringcreateSimpleQuery(java.lang.String alias)Create the simple hql query for the entity managed by the dao.voiddelete(E e)Permet de supprimer une entite.voiddeleteAll(java.lang.Iterable<E> entities)Permet de supprimer des entités.booleanexistByProperties(java.lang.String propertyName, java.lang.Object propertyValue, java.lang.Object... others)Check the existence of an entity withpropertyNamewithpropertyValue.booleanexistByTopiaId(java.lang.String id)Check the existence of an entity with technicalid.booleanexistsByQuery(java.lang.String hql, java.lang.Object... params)Check the existence of an entity using ahqlquery.java.util.List<E>findAll()Gets all entitys of the dao type in db.java.util.List<E>findAllByProperties(java.lang.String propertyName, java.lang.Object value, java.lang.Object... others)Gets all entities of the dao type matching thevaluefor the givenpropertyNameandothers.java.util.List<E>findAllByProperties(java.util.Map<java.lang.String,java.lang.Object> properties)Gets all entities of the dao type matching all theproperties.java.util.List<E>findAllByProperty(java.lang.String propertyName, java.lang.Object value)Gets all entities of the dao type matching thevaluefor the givenpropertyName.<R> java.util.List<R>findAllByQuery(java.lang.Class<R> type, java.lang.String hql, java.lang.Object... params)Gets all entities when executing the given select query for the giventypewhich may not be a entity type (int, long, map,...).java.util.List<E>findAllByQuery(java.lang.String hql, java.lang.Object... params)Gets all entities when executing the given select query for the dao entity type.<R> java.util.List<R>findAllByQueryAndPager(java.lang.Class<R> type, java.lang.String hql, TopiaPagerBean pager, java.lang.Object... params)Gets a page of entities of the given selecthqlquery using thepagerto obtain the window of entities to return.java.util.List<E>findAllByQueryAndPager(java.lang.String hql, TopiaPagerBean pager, java.lang.Object... params)Gets a page of entities of the given selecthqlquery using thepagerto obtain the window of entities to return.<R> java.util.List<R>findAllByQueryWithBound(java.lang.Class<R> type, java.lang.String hql, int startIndex, int endIndex, java.lang.Object... params)Gets a page of entities when executing the given select query for the dao entity type (will only return the window ofstartIndex - endIndexentities).java.util.List<E>findAllByQueryWithBound(java.lang.String hql, int startIndex, int endIndex, java.lang.Object... params)Gets a page of entities when executing the given select query for the dao entity type (will only return the window ofstartIndex - endIndexentities).java.util.List<E>findAllContains(java.lang.String propertyName, java.lang.Object property)Récupère toutes les entités (du type géré par ce dao) dont la collection nomméepropertyNamecontient lapropertydonnée.java.util.List<java.lang.String>findAllIds()Recuperation de tous les ids en base pour le type d'entite du dao.java.lang.Iterable<E>findAllLazyByQuery(int batchSize, java.lang.String hql, java.lang.Object... params)Gets all entities in lazy mode when executing the given select query for the dao entity type.<R> java.lang.Iterable<R>findAllLazyByQuery(java.lang.Class<R> type, int batchSize, java.lang.String hql, java.lang.Object... params)Gets all entities in lazy mode when executing the given select query for the giventypewhich may not be a entity type (int, long, map,...).<R> java.lang.Iterable<R>findAllLazyByQuery(java.lang.Class<R> type, java.lang.String hql, java.lang.Object... params)Gets all entities in lazy mode when executing the given select query for the giventypewhich may not be a entity type (int, long, map,...).java.lang.Iterable<E>findAllLazyByQuery(java.lang.String hql, java.lang.Object... params)Gets all entities in lazy mode when executing the given select query for the dao entity type.java.util.Map<java.lang.Class<? extends TopiaEntity>,java.util.List<? extends TopiaEntity>>findAllUsages(E entity)Find all usages of the givenentity.java.util.List<E>findAllWithOrder(java.lang.String... propertyNames)Gets all entites for the dao entity type order by givenpropertyNames.EfindByPrimaryKey(java.lang.Object... k)Recherche la classe en utilisant la cle naturelle, si la cle naturelle est composé de plusieurs champs alors les arguments passés doivent être dans l'ordre de declaration dans le fichier de mappingEfindByPrimaryKey(java.util.Map<java.lang.String,java.lang.Object> keys)Recherche la classe en utilisant la cle naturelle, chaque champs de la cle naturelle est une entre de la map passe en argument.EfindByProperties(java.lang.String propertyName, java.lang.Object value, java.lang.Object... others)EfindByProperties(java.util.Map<java.lang.String,java.lang.Object> properties)Find an entity matchingproperties.EfindByProperty(java.lang.String propertyName, java.lang.Object value)Find an entity matchingvaluefor the givenpropertyName.<R> RfindByQuery(java.lang.Class<R> type, java.lang.String hql, java.lang.Object... params)Execute une requête basé sur letypedonné.EfindByQuery(java.lang.String hql, java.lang.Object... params)Execute une requête basé sur l'entité du DAO.EfindByTopiaId(java.lang.String id)Find an entity corresponding to theid.EfindContains(java.lang.String propertyName, java.lang.Object property)Récupère la première entité (du type géré par ce dao) dont la collection nomméepropertyNamecontient lapropertydonnée.<R extends TopiaEntity>
java.util.List<R>findUsages(java.lang.Class<R> type, E entity)Find usages of the givenentityin the entities of the giventype.intgetBatchSize()Obtains the batch size used to load data.TopiaContextImplementorgetContext()Return context used by this DAO.java.lang.Class<E>getEntityClass()Get the type of entity managed by this DAO.TopiaEntityEnumgetTopiaEntityEnum()Get the entityEnum of the type of entity managed by this DAO.voidinit(TopiaContextImplementor context, java.lang.Class<E> entityClass)When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just after.EnewInstance()Create a new instance of managed entity not persisted.voidremoveTopiaEntityListener(TopiaEntityListener listener)voidremoveTopiaEntityVetoable(TopiaEntityVetoable vetoable)voidsetBatchSize(int batchSize)Set a new default batch size.Eupdate(E e)Permet d'ajouter ou de mettre a jour un objet.Methods inherited from interface org.nuiton.topia.persistence.TopiaDAODeprecated
countByQuery, createQuery, createQuery, existByQuery, findAllByQuery, findAllMappedByQuery, findAllMappedByQuery, findByQuery, getRequestPermission
-
Method Details
-
newInstance
Create a new instance of managed entity not persisted.- Returns:
- new entity instance
- Throws:
TopiaException- if any pb while creating the entity- Since:
- 2.3.1
-
create
Construit une nouvelle instance de l'objet géré par ce DAO- Parameters:
properties- la liste des propriétés que doit avoir l'objet créé les arguments vont par paire (propertyName, value)- Returns:
- un nouvel objet
- Throws:
TopiaException- si un problème est rencontré durant l'instanciationjava.lang.IllegalArgumentException- Si le nombre on le type des arguments n'est pas bon ou que le type ou le nom d'une propriété est fausse
-
create
Construit une nouvelle instance de l'objet géré par ce DAO- Parameters:
properties- la liste des propriétés que doit avoir l'objet créé- Returns:
- un nouvel objet
- Throws:
TopiaException- si un problème est rencontré durant l'instanciationjava.lang.IllegalArgumentException- Si le nombre on le type des arguments n'est pas bon ou que le type ou le nom d'une propriété est fausse
-
create
Permet de sauver un object instancié sans le DAO. Utilisé notement dans le cas ou le DAO est situé derriere une couche de webservice et que l'appel à la methodecreate(Object...)serait trop couteux.- Parameters:
e- l'entité instanciée à sauver- Returns:
- l'entité avec son topiaID valorisé
- Throws:
TopiaException- if any pb while creating datas- Since:
- 2.3.1
-
update
Permet d'ajouter ou de mettre a jour un objet. Cela permet d'ajouter par exemple un objet provenant d'un autre context mais du meme type de DAO.- Parameters:
e- l'entite a ajouter ou mettre a jour- Returns:
- l'entity passé en paramètre.
- Throws:
TopiaException- if any pb while updating datas
-
delete
Permet de supprimer une entite.- Parameters:
e- l'entite a supprimer- Throws:
TopiaException- if any pb while deleting datas
-
deleteAll
Permet de supprimer des entités.- Parameters:
entities- les entités à supprimer- Throws:
TopiaException- if any pb while deleting datas
-
findByTopiaId
Find an entity corresponding to theid. If theidis null, nothing will be searched.- Parameters:
id- topiaId of the entity to found- Returns:
- the entity found or null if not
- Throws:
TopiaException- for Topia errors on query
-
findByProperty
Find an entity matchingvaluefor the givenpropertyName.- Parameters:
propertyName- property name to filtervalue- value of the property to math- Returns:
- the first entity matching the request
- Throws:
TopiaException
-
findByProperties
E findByProperties(java.lang.String propertyName, java.lang.Object value, java.lang.Object... others) throws TopiaException- Parameters:
propertyName- le nom de la propriétévalue- la valeur à testerothers- les autres proprietes doivent aller par 2 propertyName, value- Returns:
- l'entité trouvé
- Throws:
TopiaException- if any pb while getting datas
-
findByProperties
E findByProperties(java.util.Map<java.lang.String,java.lang.Object> properties) throws TopiaExceptionFind an entity matchingproperties.- Parameters:
properties- les propriétés à matcher- Returns:
- l'entité trouvé
- Throws:
TopiaException- if any pb while getting datas
-
findByQuery
Execute une requête basé sur l'entité du DAO. Permet de récupérer une entité correspondant à la requête.- Parameters:
hql- la requête hql à executerparams- les paramètres de la requète- Returns:
- l'entité correspondant à la recherche ou null si aucune entité n'a été trouvée
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
-
findByQuery
<R> R findByQuery(java.lang.Class<R> type, java.lang.String hql, java.lang.Object... params) throws TopiaExceptionExecute une requête basé sur letypedonné. Permet de récupérer une entité correspondant à la requête.- Parameters:
hql- la requête hql à executerparams- les paramètres de la requète- Returns:
- l'entité correspondant à la recherche ou null si aucune entité n'a été trouvée
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
-
findByPrimaryKey
Recherche la classe en utilisant la cle naturelle, chaque champs de la cle naturelle est une entre de la map passe en argument.- Parameters:
keys- la liste des champs de la cle naturelle avec leur valeur- Returns:
- l'entite trouvé
- Throws:
TopiaException- if any pb while getting datas
-
findByPrimaryKey
Recherche la classe en utilisant la cle naturelle, si la cle naturelle est composé de plusieurs champs alors les arguments passés doivent être dans l'ordre de declaration dans le fichier de mapping- Parameters:
k- l'objet cle naturelle de la classe- Returns:
- l'entité trouvé
- Throws:
TopiaException- if any pb while getting datas
-
findContains
Récupère la première entité (du type géré par ce dao) dont la collection nomméepropertyNamecontient lapropertydonnée.- Parameters:
propertyName- le nom de la propriétéproperty- la propriété recherchée- Returns:
- la première entité recherchée
- Throws:
TopiaException- pour tout erreur lors de la recherche- Since:
- 2.5.4
-
findAll
Gets all entitys of the dao type in db.- Returns:
- all entities of the dao type in db
- Throws:
TopiaException
-
findAllIds
Recuperation de tous les ids en base pour le type d'entite du dao.- Returns:
- la liste de tous les ids
- Throws:
TopiaException- si pb en base
-
findAllByProperty
java.util.List<E> findAllByProperty(java.lang.String propertyName, java.lang.Object value) throws TopiaExceptionGets all entities of the dao type matching thevaluefor the givenpropertyName.- Parameters:
propertyName- property name to filtervalue- value to match- Returns:
- matching entities
- Throws:
TopiaException- if any pb while getting datas
-
findAllByProperties
java.util.List<E> findAllByProperties(java.lang.String propertyName, java.lang.Object value, java.lang.Object... others) throws TopiaExceptionGets all entities of the dao type matching thevaluefor the givenpropertyNameandothers.- Parameters:
propertyName- le nom de la propriétévalue- la valeur à testerothers- les autres proprietes doivent aller par 2 propertyName, value- Returns:
- matching entities
- Throws:
TopiaException- if any pb while getting datas
-
findAllByProperties
java.util.List<E> findAllByProperties(java.util.Map<java.lang.String,java.lang.Object> properties) throws TopiaExceptionGets all entities of the dao type matching all theproperties.- Parameters:
properties- properties to match- Returns:
- matching entities
- Throws:
TopiaException- if any pb while getting datas
-
findAllByQuery
java.util.List<E> findAllByQuery(java.lang.String hql, java.lang.Object... params) throws TopiaExceptionGets all entities when executing the given select query for the dao entity type.- Parameters:
hql- hql queryparams- query params- Returns:
- entites of the query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
-
findAllByQuery
<R> java.util.List<R> findAllByQuery(java.lang.Class<R> type, java.lang.String hql, java.lang.Object... params) throws TopiaExceptionGets all entities when executing the given select query for the giventypewhich may not be a entity type (int, long, map,...).- Parameters:
hql- hql queryparams- query params- Returns:
- entites of the query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
-
findAllLazyByQuery
java.lang.Iterable<E> findAllLazyByQuery(java.lang.String hql, java.lang.Object... params) throws TopiaExceptionGets all entities in lazy mode when executing the given select query for the dao entity type. Important note:- Parameters:
hql- hql queryparams- query params- Returns:
- entites of the query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.14
-
findAllLazyByQuery
<R> java.lang.Iterable<R> findAllLazyByQuery(java.lang.Class<R> type, java.lang.String hql, java.lang.Object... params) throws TopiaExceptionGets all entities in lazy mode when executing the given select query for the giventypewhich may not be a entity type (int, long, map,...). Important note:- Parameters:
type- type of data to returnhql- hql queryparams- query params- Returns:
- entites of the query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.14
-
findAllLazyByQuery
java.lang.Iterable<E> findAllLazyByQuery(int batchSize, java.lang.String hql, java.lang.Object... params) throws TopiaExceptionGets all entities in lazy mode when executing the given select query for the dao entity type. Important note:- Parameters:
batchSize- batch sizehql- hql queryparams- query params- Returns:
- entites of the query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.14
-
findAllLazyByQuery
<R> java.lang.Iterable<R> findAllLazyByQuery(java.lang.Class<R> type, int batchSize, java.lang.String hql, java.lang.Object... params) throws TopiaExceptionGets all entities in lazy mode when executing the given select query for the giventypewhich may not be a entity type (int, long, map,...). Important note:- Parameters:
type- type of data to returnbatchSize- batch sizehql- hql queryparams- query params- Returns:
- entites of the query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.14
-
findAllByQueryWithBound
<R> java.util.List<R> findAllByQueryWithBound(java.lang.Class<R> type, java.lang.String hql, int startIndex, int endIndex, java.lang.Object... params) throws TopiaExceptionGets a page of entities when executing the given select query for the dao entity type (will only return the window ofstartIndex - endIndexentities).- Parameters:
hql- hql query to executestartIndex- first index of entity to returnendIndex- last index of entity to returnparams- query params- Returns:
- entites of the paginated query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
-
findAllByQueryWithBound
java.util.List<E> findAllByQueryWithBound(java.lang.String hql, int startIndex, int endIndex, java.lang.Object... params) throws TopiaExceptionGets a page of entities when executing the given select query for the dao entity type (will only return the window ofstartIndex - endIndexentities).- Parameters:
hql- hql query to executestartIndex- first index of entity to returnendIndex- last index of entity to returnparams- query params- Returns:
- entites of the paginated query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
-
findAllByQueryAndPager
<R> java.util.List<R> findAllByQueryAndPager(java.lang.Class<R> type, java.lang.String hql, TopiaPagerBean pager, java.lang.Object... params) throws TopiaExceptionGets a page of entities of the given selecthqlquery using thepagerto obtain the window of entities to return.- Parameters:
type- type of data to returnhql- hql query to executepager- pager to obtan the correct window of dataparams- params of the query- Returns:
- entities of the paginated query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
- See Also:
TopiaPagerBean
-
findAllByQueryAndPager
java.util.List<E> findAllByQueryAndPager(java.lang.String hql, TopiaPagerBean pager, java.lang.Object... params) throws TopiaExceptionGets a page of entities of the given selecthqlquery using thepagerto obtain the window of entities to return.- Parameters:
hql- hql query to executepager- pager to obtan the correct window of dataparams- params of the query- Returns:
- entities of the paginated query result
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
- See Also:
TopiaPagerBean
-
findAllWithOrder
Gets all entites for the dao entity type order by givenpropertyNames. You can add on eachpropertyASCouDESCto fix order way (by default isASC).- Parameters:
propertyNames- property names of order to apply- Returns:
- all entities of the dao entity type with given order
- Throws:
TopiaException- if any pb while getting datas
-
findAllContains
java.util.List<E> findAllContains(java.lang.String propertyName, java.lang.Object property) throws TopiaExceptionRécupère toutes les entités (du type géré par ce dao) dont la collection nomméepropertyNamecontient lapropertydonnée.- Parameters:
propertyName- le nom de la propriétéproperty- la propriété recherchée- Returns:
- toutes les entités recherchées
- Throws:
TopiaException- pour tout erreur lors de la recherche- Since:
- 2.5.4
-
existByTopiaId
Check the existence of an entity with technicalid.- Parameters:
id- unique id of the entity to test existence.- Returns:
- true if entity exists, false otherwise
- Throws:
TopiaException- for Topia errors- Since:
- 2.3.4
-
existByProperties
boolean existByProperties(java.lang.String propertyName, java.lang.Object propertyValue, java.lang.Object... others) throws TopiaExceptionCheck the existence of an entity withpropertyNamewithpropertyValue.othersproperties can be added to test existence.- Parameters:
propertyName- first property name to test existencepropertyValue- first property value to test existenceothers- altern propertyName and propertyValue- Returns:
- true if entity exists, false otherwise
- Throws:
TopiaException- for Topia errors- Since:
- 2.3.4
-
existsByQuery
Check the existence of an entity using ahqlquery.- Parameters:
hql- query used to test existenceparams- params used by the query- Returns:
- true if entity exists, false otherwise
- Throws:
TopiaException- Since:
- 2.6.12
-
count
Count the number of existing entities.- Returns:
- number of total entities
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.3.4
-
countByQuery
Count the number of entities based on ahql.- Parameters:
hql- hql query to use- Returns:
- number of entities filtered by the query
- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
-
findUsages
<R extends TopiaEntity> java.util.List<R> findUsages(java.lang.Class<R> type, E entity) throws TopiaExceptionFind 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 of the given type which uses the given entity
- Throws:
TopiaException- if any problem while getting data- Since:
- 2.3.0
-
findAllUsages
java.util.Map<java.lang.Class<? extends TopiaEntity>,java.util.List<? extends TopiaEntity>> findAllUsages(E entity) throws TopiaExceptionFind 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).
- Throws:
TopiaException- if any pb while getting data- Since:
- 2.3.0
-
computeAndAddRecordsToPager
void computeAndAddRecordsToPager(java.lang.String hql, TopiaPagerBean pager, java.lang.Object... params) throws TopiaExceptionExecute the counthqlquery and then synch the pager to this result (says fill thePagerBean.getRecords()field and then adapt the number of pages available and the current number page).- Parameters:
hql- the count hql to executepager- the page to synchparams- params of the count query- Throws:
TopiaException- if any pb while getting datas- Since:
- 2.6.12
- See Also:
TopiaPagerBean
-
getTopiaEntityEnum
TopiaEntityEnum getTopiaEntityEnum()Get the entityEnum of the type of entity managed by this DAO.- Returns:
- entity type enum managed by this DAO
-
getEntityClass
java.lang.Class<E> getEntityClass()Get the type of entity managed by this DAO.- Returns:
- entity type managed by this DAO
-
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
-
init
When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just after.- Parameters:
context- contextentityClass- entity class- Throws:
TopiaException- if any pb while init
-
getContext
TopiaContextImplementor getContext()Return context used by this DAO.- Returns:
- the context.
-
createSimpleQuery
java.lang.String createSimpleQuery(java.lang.String alias)Create the simple hql query for the entity managed by the dao. A optional alias can be passed:FROM MyEntityImpl myAlias
- Parameters:
alias- optional alias to use in query- Returns:
- the hql query
- Since:
- 2.6.14
-
addTopiaEntityListener
-
addTopiaEntityVetoable
-
removeTopiaEntityListener
-
removeTopiaEntityVetoable
-