org.nuiton.topia.persistence
Interface TopiaDAO<E extends TopiaEntity>

Type Parameters:
E - the entity type linked with the dao
All Known Implementing Classes:
TopiaDAOImpl, TopiaDAOLegacy

public interface TopiaDAO<E extends TopiaEntity>

TopiaDAO is used to manipulate entities corresponding to E type : create, delete, update or find entities using properties of TopiaQuery.

This interface is implemented by TopiaDAOImpl overriden by generation from DAOTransformer for specific entity interface, DAOAbstractTransformer for abstract implementation and DAOImplTransformer for final implementation class.

TODO-fdesbois-20100508 : Need translation of javadoc.

Version:
$Id: TopiaDAO.java 2010 2010-06-13 18:18:35Z tchemit $
Author:
poussin , fdesbois

Method Summary
 void addTopiaEntityListener(TopiaEntityListener listener)
           
 void addTopiaEntityVetoable(TopiaEntityVetoable vetoable)
           
 void commitTransaction()
          Deprecated. since 2.3.4 do nothing in dao implementation generated, not well placed
 int count()
          Count the number of existing entities.
 int countByQuery(TopiaQuery query)
          Count the number of entities based on query.
 E create(E e)
          Permet de sauver un object instancié sans le DAO.
 E create(Map<String,Object> properties)
          Construit une nouvelle instance de l'objet géré par ce DAO
 E create(Object... properties)
          Construit une nouvelle instance de l'objet géré par ce DAO
 TopiaQuery createQuery()
          Crée une requete basé sur l'entité lié au DAO.
 TopiaQuery createQuery(String entityAlias)
          Crée une requête basé sur l'entité lié au DAO et lui assigne un alias valable dans la requête..
 void delete(E e)
          Permet de supprimer une entite.
 boolean existByProperties(String propertyName, Object propertyValue, Object... others)
          Check the existence of an entity with propertyName with propertyValue.
 boolean existByQuery(TopiaQuery query)
          Check the existence of an entity using a query.
 boolean existByTopiaId(String id)
          Check the existence of an entity with technical id.
 List<E> findAll()
           
 List<E> findAllByProperties(Map<String,Object> properties)
           
 List<E> findAllByProperties(String propertyName, Object value, Object... others)
           
 List<E> findAllByProperty(String propertyName, Object value)
           
 List<E> findAllByQuery(TopiaQuery query)
          Execute une requête basé sur l'entité du DAO.
 List<E> findAllContainsProperties(Map<String,Collection<?>> properties)
          Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead
 List<E> findAllContainsProperties(String propertyName, Collection<?> values, Object... others)
          Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead
 List<String> findAllIds()
          Recuperation de tous les ids en base pour le type d'entite du dao.
 Map<String,E> findAllMappedByQuery(TopiaQuery query)
          Execute une requête basé sur l'entité du DAO.
<K> Map<K,E>
findAllMappedByQuery(TopiaQuery query, String keyName, Class<K> keyClass)
          Execute une requête basé sur l'entité du DAO.
 Map<Class<? extends TopiaEntity>,List<? extends TopiaEntity>> findAllUsages(E entity)
          Find all usages of the given entity.
 List<E> findAllWithOrder(String... propertyNames)
           
 E findByPrimaryKey(Map<String,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.
 E findByPrimaryKey(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 mapping
 E findByProperties(Map<String,Object> properties)
           
 E findByProperties(String propertyName, Object value, Object... others)
           
 E findByProperty(String propertyName, Object value)
           
 E findByQuery(TopiaQuery query)
          Execute une requête basé sur l'entité du DAO.
 E findByTopiaId(String id)
          Find an entity corresponding to the id.
 E findContainsProperties(Map<String,Collection<?>> properties)
          Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead
 E findContainsProperties(String propertyName, Collection<?> values, Object... others)
          Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead
<U extends TopiaEntity>
List<U>
findUsages(Class<U> type, E entity)
          Find usages of the given entity in the entities of the given type.
 TopiaContextImplementor getContext()
          Return context used by this DAO.
 Class<E> getEntityClass()
          Return class of entity managed by this DAO.
 List<Permission> getRequestPermission(String topiaId, int actions)
          Retourne les permissions a verifier pour l'acces a l'entite pour le service Taas.
 void init(TopiaContextImplementor context, Class<E> entityClass)
          When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just after.
 E newInstance()
          Create a new instance of managed entity.
 void removeTopiaEntityListener(TopiaEntityListener listener)
           
 void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable)
           
 void rollbackTransaction()
          Deprecated. since 2.3.4 do nothing in dao implementation generated, not well placed
 long size()
          Deprecated. since 2.3.4 ambiguous name, use count() instead.
 E update(E e)
          Permet d'ajouter ou de mettre a jour un objet.
 

Method Detail

init

void init(TopiaContextImplementor context,
          Class<E> entityClass)
          throws TopiaException
When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just after.

Parameters:
context - context
entityClass - entity class
Throws:
TopiaException - if any pb while init

newInstance

E newInstance()
                                  throws TopiaException
Create a new instance of managed entity.

Returns:
new entity instance
Throws:
TopiaException - if any pb while creating the entitie
Since:
2.3.1

getEntityClass

Class<E> getEntityClass()
Return class of entity managed by this DAO.

Returns:
entity managed by this DAO

getContext

TopiaContextImplementor getContext()
Return context used by this DAO.

Returns:
Returns the context.

commitTransaction

@Deprecated
void commitTransaction()
                       throws TopiaException
Deprecated. since 2.3.4 do nothing in dao implementation generated, not well placed

Appelé lorsque le context a eu un commit de fait.

TODO il faudrait peut-etre plutot faire un commit a deux phase car plusieurs type de persistence peuvent etre melangé, et il serait bien que si l'une echoué les autres echoue aussi.

Throws:
TopiaException - if any pb while commit

rollbackTransaction

@Deprecated
void rollbackTransaction()
                         throws TopiaException
Deprecated. since 2.3.4 do nothing in dao implementation generated, not well placed

Appelé lorsque le context a eu un rollback de fait.

Throws:
TopiaException - if any pb while rollback

findUsages

<U extends TopiaEntity> List<U> findUsages(Class<U> type,
                                           E entity)
                                       throws TopiaException
Find usages of the given entity in the entities of the given type.

Type Parameters:
U - tthe type of entity to search
Parameters:
type - the type of entity to search
entity - the entity
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

Map<Class<? extends TopiaEntity>,List<? extends TopiaEntity>> findAllUsages(E entity)
                                                                            throws TopiaException
Find all usages of the given entity.

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

getRequestPermission

List<Permission> getRequestPermission(String topiaId,
                                      int actions)
                                      throws TopiaException
Retourne les permissions a verifier pour l'acces a l'entite pour le service Taas.

Parameters:
topiaId - topiaId d'une entite
actions - encoded actions
Returns:
la liste des permissions
Throws:
TopiaException - if any pb while getting datas

addTopiaEntityListener

void addTopiaEntityListener(TopiaEntityListener listener)

addTopiaEntityVetoable

void addTopiaEntityVetoable(TopiaEntityVetoable vetoable)

removeTopiaEntityListener

void removeTopiaEntityListener(TopiaEntityListener listener)

removeTopiaEntityVetoable

void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable)

create

E create(Object... properties)
                             throws TopiaException
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'instanciation
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

E create(Map<String,Object> properties)
                             throws TopiaException
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'instanciation
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

E create(E e)
                             throws TopiaException
Permet de sauver un object instancié sans le DAO.

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

E update(E e)
                             throws TopiaException
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

void delete(E e)
            throws TopiaException
Permet de supprimer une entite.

Parameters:
e - l'entite a supprimer
Throws:
TopiaException - if any pb while deleting datas

createQuery

TopiaQuery createQuery()
Crée une requete basé sur l'entité lié au DAO. Résultat attendu : "FROM E"

Returns:
une nouvelle TopiaQuery vide. (uniquement avec le From sur le type d'entité)
Since:
2.3

createQuery

TopiaQuery createQuery(String entityAlias)
Crée une requête basé sur l'entité lié au DAO et lui assigne un alias valable dans la requête..

Résultat attendu : "FROM E AS entityAlias"

Parameters:
entityAlias - alias permettant de manipuler l'entité dans la requête
Returns:
une nouvelle TopiaQuery
Since:
2.3

findByTopiaId

E findByTopiaId(String id)
                                    throws TopiaException
Find an entity corresponding to the id. If the id is null, nothing will be search.

Parameters:
id - topiaId of the entity to found
Returns:
the entity found or null if not
Throws:
TopiaException - for Topia errors on query

findByProperty

E findByProperty(String propertyName,
                 Object value)
                                     throws TopiaException
Throws:
TopiaException

findByProperties

E findByProperties(String propertyName,
                   Object value,
                   Object... others)
                                       throws TopiaException
Parameters:
propertyName - le nom de la propriété
value - la valeur à tester
others - les autres proprietes doivent aller par 2 propertyName, value
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findByProperties

E findByProperties(Map<String,Object> properties)
                                       throws TopiaException
Throws:
TopiaException

findByQuery

E findByQuery(TopiaQuery query)
                                  throws TopiaException
Execute une requête basé sur l'entité du DAO. Permet de récupérer une entité correspondant à la requête.

Parameters:
query - 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.3
See Also:
TopiaQuery.executeToEntity(TopiaContext, Class)

findAll

List<E> findAll()
                                    throws TopiaException
Throws:
TopiaException

findAllIds

List<String> findAllIds()
                        throws TopiaException
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

List<E> findAllByProperty(String propertyName,
                          Object value)
                                              throws TopiaException
Throws:
TopiaException

findAllByProperties

List<E> findAllByProperties(String propertyName,
                            Object value,
                            Object... others)
                                                throws TopiaException
Parameters:
propertyName - le nom de la propriété
value - la valeur à tester
others - les autres proprietes doivent aller par 2 propertyName, value
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findAllByProperties

List<E> findAllByProperties(Map<String,Object> properties)
                                                throws TopiaException
Throws:
TopiaException

findAllByQuery

List<E> findAllByQuery(TopiaQuery query)
                                           throws TopiaException
Execute une requête basé sur l'entité du DAO. Permet de récupérer une liste d'entités correspondant à la requête.

Parameters:
query - la requête
Returns:
la liste d'entités correspondant à la recherche
Throws:
TopiaException - if any pb while getting datas
Since:
2.3
See Also:
TopiaQuery.executeToEntityList(TopiaContext, Class)

findAllMappedByQuery

Map<String,E> findAllMappedByQuery(TopiaQuery query)
                                                       throws TopiaException
Execute une requête basé sur l'entité du DAO. Permet de récupérer une map d'entités correspondant à la requête. La clé de la map étant le topiaId de l'entité.

Parameters:
query - la requête
Returns:
la map d'entités correspondant à la recherche
Throws:
TopiaException - if any pb while getting datas
Since:
2.3
See Also:
TopiaQuery.executeToEntityMap(TopiaContext, Class)

findAllMappedByQuery

<K> Map<K,E> findAllMappedByQuery(TopiaQuery query,
                                  String keyName,
                                  Class<K> keyClass)
                                                  throws TopiaException
Execute une requête basé sur l'entité du DAO. Permet de récupérer une map d'entités correspondant à la requête. Le type et le nom de la propriété utilisé comme clé de la map doit être passé en argument.

Type Parameters:
K - type de la clé de la map
Parameters:
query - la requête
keyName - nom de la propriété de l'entité utilisée comme clé
keyClass - type de la propriété de l'entité utilisée comme clé
Returns:
la map d'entités correspondant à la recherche
Throws:
TopiaException - if any pb while getting datas
Since:
2.3
See Also:
TopiaQuery.executeToEntityMap(TopiaContext, Class)

findAllWithOrder

List<E> findAllWithOrder(String... propertyNames)
                                             throws TopiaException
Throws:
TopiaException

existByTopiaId

boolean existByTopiaId(String id)
                       throws TopiaException
Check the existence of an entity with technical id.

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(String propertyName,
                          Object propertyValue,
                          Object... others)
                          throws TopiaException
Check the existence of an entity with propertyName with propertyValue. others properties can be added to test existence.

Parameters:
propertyName - first property name to test existence
propertyValue - first property value to test existence
others - altern propertyName and propertyValue
Returns:
true if entity exists, false otherwise
Throws:
TopiaException - for Topia errors
Since:
2.3.4

existByQuery

boolean existByQuery(TopiaQuery query)
                     throws TopiaException
Check the existence of an entity using a query.

Parameters:
query - query used to test existence
Returns:
true if entity exists, false otherwise
Throws:
TopiaException
Since:
2.3.4

size

@Deprecated
long size()
          throws TopiaException
Deprecated. since 2.3.4 ambiguous name, use count() instead.

Compte le nombre d'entites en base

Returns:
le nombre total d'entites existantes
Throws:
TopiaException - if any pb while getting datas

count

int count()
          throws TopiaException
Count the number of existing entities.

Returns:
number of total entities
Throws:
TopiaException - if any pb while getting datas
Since:
2.3.4

countByQuery

int countByQuery(TopiaQuery query)
                 throws TopiaException
Count the number of entities based on query.

Returns:
number of entities filtered by the query
Throws:
TopiaException - if any pb while getting datas
Since:
2.3.4

findByPrimaryKey

E findByPrimaryKey(Map<String,Object> keys)
                                       throws TopiaException
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

E findByPrimaryKey(Object... k)
                                       throws TopiaException
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

findContainsProperties

@Deprecated
E findContainsProperties(Map<String,Collection<?>> properties)
                                             throws TopiaException
Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead

Cherche et renvoie la première entité trouvée dont les propriétés en clé de Map contiennent toutes les valeurs de la Collection.

Parameters:
properties - les proprietes a utiliser
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findContainsProperties

@Deprecated
E findContainsProperties(String propertyName,
                                    Collection<?> values,
                                    Object... others)
                                             throws TopiaException
Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead

Cherche et renvoie la première entité trouvée dont la propriété propertyName contient values, ainsi de suite avec others.

Parameters:
propertyName - le nom de la propriété
values - les premières valeurs à tester
others - les secondes valeurs ) tester
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findAllContainsProperties

@Deprecated
List<E> findAllContainsProperties(Map<String,Collection<?>> properties)
                                                      throws TopiaException
Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead

Cherche et renvoie la première entité trouvée dont les propriétés en clé de Map contiennent toutes les valeurs de la Collection.

Parameters:
properties - les propriétés à tester
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas

findAllContainsProperties

@Deprecated
List<E> findAllContainsProperties(String propertyName,
                                             Collection<?> values,
                                             Object... others)
                                                      throws TopiaException
Deprecated. since 2.3.4 strange method, not very useful, use TopiaQuery instead

Cherche et renvoie toutes les entités trouvées dont la propriété propertyName contient values, ainsi de suite avec others.

Parameters:
propertyName - the name of the property
values - les premières valeurs à tester
others - les secondes valeurs à tester
Returns:
l'entité trouvé
Throws:
TopiaException - if any pb while getting datas


Copyright © 2004-2010 CodeLutin. All Rights Reserved.