org.nuiton.topia.framework
Class TopiaQuery<E extends TopiaEntity>

java.lang.Object
  extended by org.nuiton.topia.framework.TopiaQuery<E>
Type Parameters:
E - The main entity for the query

public class TopiaQuery<E extends TopiaEntity>
extends Object

Query HQL managment to simplify usage of TopiaContext.find(java.lang.String, java.lang.Object[]). TODO-FD20091224 Complete documentation of this class + JUnit Tests

 This class is used to construct a HQL query and then execute it from a TopiaContext. The TopiaQuery is linked to a TopiaEntity which
 is the main element manipulated in the query. There is two parts in using this class :
 - construction of the query, using add, addFrom, addOrder, addSelect, addGroup, ...
 - execution of the query, using executeToEntityList, executeToEntity, executeToInteger, ...

 Construction
 ============

 This class make easier the way to construct a HQL query.
 
 Example 1 :
 -----------

 SQL :
       "SELECT * FROM PersonImpl WHERE firstName LIKE 'M%' AND year > 1980"

 HQL using TopiaContext.find(java.lang.String, java.lang.Object[]) :
       TopiaContext context = rootContext.beginTransaction();
       context.find("FROM " + Person.class.getName() + " WHERE firstName LIKE :firstName AND year > :year",
              "firstName", "M%", year, 1980);

 TopiaQuery : 
       TopiaQuery query = TopiaQuery.createQuery(Person.class).add(Person.FIRST_NAME, Op.LIKE, "M%").add(Person.YEAR, Op.GT, 1980);

 But the real advantage is when you have some parameters to test before adding them to the query. With the older method, it was tidious to construct
 and add parameters to finally use the find method from TopiaContext.

 Example 2 :
 -----------

 HQL using TopiaContext.find(java.lang.String, java.lang.Object[]) :
       TopiaContext context = rootContext.beginTransaction();

       String query = "FROM " + Person.class.getName();
       List params = new ArrayList();
       boolean filtered = false;
       // company parameter can be null
       if (company != null) {
           query += " WHERE company = :company";
           params.add("company");
           params.add(company);
           filtered = true;
       }

       // contact paramater can be null
       if (contact != null) {
           query += filtered ? " AND " : " WHERE "
           query += " contact = :contact";
           params.add("contact");
           params.add(contact);
           filtered = true;
       }

       context.find(query, params.toArray());

 Here we have only two non obligatory params, but imagine if we must have almost 6 or 7 parameters like this !

 TopiaQuery :
       TopiaQuery query = TopiaQuery.createQuery(Person.class);

       if (company != null) {
           query.add(Person.COMPANY, company);
       }

       if (contact != null) {
           query.add(Person.CONTACT, contact);
       }

 Many ways to create the same query :
 ------------------------------------

 You can use multiple different manners to create a query, it depends on the complexicity. More complex is the query, more easier is to construct it.

 HQL : "FROM PersonImpl AS P WHERE (P.company IS NULL OR P.company = :company) AND P.firstName LIKE :firstName"

 Using TopiaQuery and an Alias :
 query = TopiaQuery.createQuery(Person.class, "P");
 1- query.add("(P.company IS NULL OR P.company = :company") AND P.firstName LIKE :firstName").addParam("company", company).addParam("firstName",firstName + "%");
 2- query.add("P.company IS NULL OR P.company = :company").add("P.firstName LIKE :firstName").addParam("company", company).addParam("firstName",firstName + "%");
 3- query.add("P.company IS NULL OR P.company = :company").add("P.firstName", Op.LIKE, firstName + "%").addParam("company", company);

 You can use TopiaQuery to create a subquery in an other TopiaQuery, you have to use the method fullQuery() to get the full query in HQL and give
 it as a string in the other TopiaQuery.

 Execution
 =========

 After construction, you can execute the query in different ways.

 Default method :
 ----------------

 - execute : as the same result as TopiaContext.find(java.lang.String, java.lang.Object[])

 Depends on entity type ;
 ------------------------

 - executeToEntity : only one result, the first one
 - executeToEntityList : all results returned in a List
 - executeToEntityMap : all results returned in a Map with key defined by user or topiaId by default

 For aggregate :
 ---------------

 These methods have in argument the SELECT to execute the query. The previous SELECT (if defined) will not be deleted, but temporarly not used.

 - executeToInteger : for example for "SUM", "COUNT"
 - executeToString : for example for "MAX"
 - executeCount : directly a "count(*)"
 - executeToObject : for other type of possible result (Long, Boolean, Double, ...)

 Property loading
 ================

 When using Hibernate, some times, Entities linked to the main one will be lazy initialized, but you want them directly when the
 query will be executed to avoid problems when closing context. You can use the method addLoad(java.lang.String[]) to
 tell the TopiaQuery to load some properties when executing the query. After that, you don't need to call them for loading them in Hibernate.

 The syntax is the same as a property in HQL query using delegation : "person.company" where person and company are entities.

 Note : loading only available on collection or entities but not property on a collection of entities which must be made manually.

 For a Contact which is linked to a person (entity) and the person linked to company (entity) you can add to a TopiaQuery :
       query.addLoad("person.company")

 For a list of addresses (entity) in the contact you can do :
       query.addLoad("addresses")

 But it's not possible to do for example with meeting (entity) linked to the contact and responsible (entity) linked to a meeting :
       query.addLoad("meetings.responsible")

 

 Created: 21 déc. 2009

Since:
2.3.0 Mise a jour: $Date: 2010-01-20 11:40:14 +0100 (mer., 20 janv. 2010) $ par : $Author$
Version:
$Revision: 1770 $
Author:
fdesbois

Nested Class Summary
static class TopiaQuery.Op
          Enum to simmplify using operation in query
 
Field Summary
protected  TopiaDAO<E> dao
           
protected  boolean distinct
           
protected  Integer endIndex
           
protected  String from
          From part of the query
protected  String groupBy
          Group By part of the query
protected  String mainAlias
           
protected  Class<E> mainEntityClass
           
protected  String orderBy
          Order By part of the query
protected  List<Object> params
          Params for HQL query
protected  boolean parentheses
          Used to determine if parentheses are needed for Where input
protected  List<String> propertiesToLoad
           
protected  String select
          Select part of the query
protected  Integer startIndex
           
protected  String where
          Where part of the query
 
Constructor Summary
protected TopiaQuery(Class<E> entityClass)
           
protected TopiaQuery(Class<E> entityClass, String alias)
           
protected TopiaQuery(TopiaDAO<E> dao)
           
protected TopiaQuery(TopiaDAO<E> dao, String alias)
           
 
Method Summary
 TopiaQuery<E> add(Map<String,Object> properties)
          Add a map of properties to the where clause of the query.
 TopiaQuery<E> add(String where)
          Add a where element to the Query.
 TopiaQuery<E> add(String paramName, Collection<Object> values)
          Add an element to the query with a list of different possible values.
 TopiaQuery<E> add(String paramName, Collection<Object> values, boolean isNull)
          Add an element to the query with a list of different values.
 TopiaQuery<E> add(String paramName, Object paramValue)
          Add an element to the query.
 TopiaQuery<E> add(String paramName, TopiaQuery.Op constraint, Object paramValue)
          Add an element to the query.
 TopiaQuery<E> addDistinct()
          Add the distinct key word in the query.
 TopiaQuery<E> addFrom(String str)
          Add an element to the from in the query.
 TopiaQuery<E> addGroup(String group)
          Add an element to the group of the query.
 TopiaQuery<E> addLoad(String... properties)
          Add a property to load when query is executed.
 TopiaQuery<E> addNotNull(String paramName)
          Add an element to the query with the constraint Not null.
 TopiaQuery<E> addOrder(String order)
          Add an element to the order in the query.
 TopiaQuery<E> addOrderDesc(String order)
           
 TopiaQuery<E> addParam(String id, Object paramValue)
          Add a HQL parameter to the Query.
 TopiaQuery<E> addSelect(String select)
          Add an element to the select in the query.
static
<T extends TopiaEntity>
TopiaQuery<T>
createQuery(Class<T> entityClass)
          Create a TopiaQuery with entityClass initialization.
static
<T extends TopiaEntity>
TopiaQuery<T>
createQuery(Class<T> entityClass, String alias)
          Create a TopiaQuery with entityClass initialization and its Alias.
static
<T extends TopiaEntity>
TopiaQuery<T>
createQuery(TopiaDAO<T> dao)
          Create a TopiaQuery from a DAO.
static
<T extends TopiaEntity>
TopiaQuery<T>
createQuery(TopiaDAO<T> dao, String alias)
          Create a TopiaQuery from a DAO with an Alias.
 List execute()
          DAO must be defined to use this method.
 List execute(TopiaContext transaction)
          Simple execution of the query.
 int executeCount()
          DAO must be defined to use this method.
 int executeCount(TopiaContext transaction)
          Execute a simple count on the query, i.e. the number of results get from the query.
 E executeToEntity()
          DAO must be defined to use this method.
 E executeToEntity(TopiaContext transaction)
          Execute the query and get the first result entity.
 List<E> executeToEntityList()
          DAO must be defined to use this method.
 List<E> executeToEntityList(TopiaContext transaction)
          Execute the query and get a List of entity.
 Map<String,E> executeToEntityMap()
          DAO must be defined to use this method.
<K> Map<K,E>
executeToEntityMap(String keyName, Class<K> keyClass)
          DAO must be defined to use this method.
 Map<String,E> executeToEntityMap(TopiaContext transaction)
          Execute the query and get a Map of entity with topiaId in key.
<K> Map<K,E>
executeToEntityMap(TopiaContext transaction, String keyName, Class<K> keyClass)
          Execute the query and get a Map of entity with key type in argument.
 int executeToInteger(String select)
          DAO must be defined to use this method.
 int executeToInteger(TopiaContext transaction, String select)
          Execute the query and get an Integer for result.
 Object executeToObject(String select)
          DAO must be defined to use this method.
 Object executeToObject(TopiaContext transaction, String select)
          Execute the query and get an Object for result.
 String executeToString(String select)
          DAO must be defined to use this method.
 String executeToString(TopiaContext transaction, String select)
          Execute the query and get a String for result.
 String fullQuery()
          Get the full query.
 String getMainAlias()
          Return the mainAlias set from constructor.
protected  List<Object> getParams()
           
protected  List<String> getPropertiesToLoad()
           
protected  String getValueName(String paramName)
           
protected
<T extends TopiaEntity>
TopiaEntity
loadEntityProperty(T entity, String property)
          Load a property of type TopiaEntity from an other entity.
protected
<T extends TopiaEntity>
void
loadProperties(T entity)
          Load all properties for the entity.
protected
<T extends TopiaEntity>
Object
loadProperty(T entity, String property)
          Load a property from an entity.
protected  void resetLimit()
           
 TopiaQuery<E> setLimit(int start, int end)
          Limit the result of the query with startIndex and endIndex.
 TopiaQuery<E> setMaxResults(int max)
          Set the max results wanted for the query.
 TopiaQuery<E> setSelect(String select)
          Set the select in the query.
 String toString()
           
protected  boolean validateDAO()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

params

protected List<Object> params
Params for HQL query


select

protected String select
Select part of the query


distinct

protected boolean distinct

from

protected String from
From part of the query


where

protected String where
Where part of the query


orderBy

protected String orderBy
Order By part of the query


groupBy

protected String groupBy
Group By part of the query


startIndex

protected Integer startIndex

endIndex

protected Integer endIndex

parentheses

protected boolean parentheses
Used to determine if parentheses are needed for Where input


propertiesToLoad

protected List<String> propertiesToLoad

mainEntityClass

protected Class<E extends TopiaEntity> mainEntityClass

mainAlias

protected String mainAlias

dao

protected TopiaDAO<E extends TopiaEntity> dao
Constructor Detail

TopiaQuery

protected TopiaQuery(Class<E> entityClass)

TopiaQuery

protected TopiaQuery(TopiaDAO<E> dao)

TopiaQuery

protected TopiaQuery(Class<E> entityClass,
                     String alias)

TopiaQuery

protected TopiaQuery(TopiaDAO<E> dao,
                     String alias)
Method Detail

createQuery

public static <T extends TopiaEntity> TopiaQuery<T> createQuery(Class<T> entityClass)
Create a TopiaQuery with entityClass initialization.

Type Parameters:
T - entity type extends TopiaEntity
Parameters:
entityClass - Class for an entity Query
Returns:
the new TopiaQuery

createQuery

public static <T extends TopiaEntity> TopiaQuery<T> createQuery(TopiaDAO<T> dao)
Create a TopiaQuery from a DAO.

Type Parameters:
T - entity type in the dao extends TopiaEntity
Parameters:
dao - DAO linked to the entity to threat
Returns:
the new TopiaQuery

createQuery

public static <T extends TopiaEntity> TopiaQuery<T> createQuery(Class<T> entityClass,
                                                                String alias)
Create a TopiaQuery with entityClass initialization and its Alias. The main entity will be automatically added to the select part of the query if it is needed.

Type Parameters:
T - entity type in the dao extends TopiaEntity
Parameters:
entityClass - Class for an entity Query
alias - of the main entity in the query
Returns:
the new TopiaQuery

createQuery

public static <T extends TopiaEntity> TopiaQuery<T> createQuery(TopiaDAO<T> dao,
                                                                String alias)
Create a TopiaQuery from a DAO with an Alias. The main entity will be automatically added to the select part of the query if it is needed.

Type Parameters:
T - entity type in the dao extends TopiaEntity
Parameters:
dao - DAO linked to the entity to threat
alias - of the main entity in the query
Returns:
the new TopiaQuery

toString

public String toString()
Overrides:
toString in class Object

fullQuery

public String fullQuery()
Get the full query.

Returns:
a String corresponding to the full query.

addParam

public TopiaQuery<E> addParam(String id,
                              Object paramValue)
Add a HQL parameter to the Query.

Parameters:
id - identification of the param in the query
paramValue - value of the param
Returns:
the TopiaQuery

getParams

protected List<Object> getParams()

getMainAlias

public String getMainAlias()
Return the mainAlias set from constructor.

Returns:
a String or null if no alias is set

addLoad

public TopiaQuery<E> addLoad(String... properties)
Add a property to load when query is executed. Used to avoid LazyInitializationException for property needed after closing context. The property is a string like those in HQL query.
 Exemples :
 - "person.company" (Property TopiaEntity person linked to the result entity in query and company linked to person)
   --> calling myEntity.getPerson().getCompany();
 - "partyRoles" (Property Collection partyRoles linked to the result entity in query)
   --> calling myEntity.getPartyRoles().size();
 

Parameters:
properties -
Returns:
the TopiaQuery

getPropertiesToLoad

protected List<String> getPropertiesToLoad()

add

public TopiaQuery<E> add(String where)
Add a where element to the Query. Could be anything. Parentheses are added automatically (even if there are not needed).

Parameters:
where - element to add
Returns:
the TopiaQuery

add

public TopiaQuery<E> add(String paramName,
                         TopiaQuery.Op constraint,
                         Object paramValue)
Add an element to the query. The parameter will be automatically added. The constraint is needed to determine what type of operation it is. Ex : add("boat", Op.EQ, boat) means -> boat = :boat.

Parameters:
paramName - the name of the parameter in the query (attribute of the entity)
constraint - the operation concerned
paramValue - the value of the parameter (an other entity, a String, ...)
Returns:
the TopiaQuery

getValueName

protected String getValueName(String paramName)

addNotNull

public TopiaQuery<E> addNotNull(String paramName)
Add an element to the query with the constraint Not null.

Parameters:
paramName - name of the parameter in the query
Returns:
the TopiaQuery

add

public TopiaQuery<E> add(String paramName,
                         Object paramValue)
Add an element to the query. The parameter will be automatically added. The default constrainst operation is Op.EQ for EQUALS. Ex : add("boat", boat) means -> boat = :boat.

Parameters:
paramName - name of the parameter in the query
paramValue - value of the parameter
Returns:
the TopiaQuery
See Also:
add(String, TopiaQuery.Op, Object)

add

public TopiaQuery<E> add(String paramName,
                         Collection<Object> values)
Add an element to the query with a list of different possible values.

Parameters:
paramName - name of the parameter in the query
values - different values for this parameter
Returns:
the TopiaQuery
See Also:
add(java.lang.String, java.util.Collection, boolean)

add

public TopiaQuery<E> add(String paramName,
                         Collection<Object> values,
                         boolean isNull)
Add an element to the query with a list of different values. The IN key word will be used to set the different values. An other constraint on nullity can be set with isNull argument. The element can have one of the value from the collection or can be null if the isNull argument is true.

Parameters:
paramName - name of the parameter in the query
values - different values for this parameter
isNull - use it to test the nullity of parameter
Returns:
the TopiaQuery
See Also:
add(java.lang.String)

add

public TopiaQuery<E> add(Map<String,Object> properties)
Add a map of properties to the where clause of the query. Each property will be added to the query with Op.EQ operation, the key in the map is the property name, and the value is the value of the parameter in the query.

Parameters:
properties -
Returns:
the TopiaQuery

addFrom

public TopiaQuery<E> addFrom(String str)
Add an element to the from in the query. Used to add some other data in the query or for join.

Parameters:
str - the element to add
Returns:
the TopiaQuery

addSelect

public TopiaQuery<E> addSelect(String select)
Add an element to the select in the query. Depends on the result wanted in execute methods. The main entity will be automatically added only if an alias is initialize from constructor. If you want only this select element, use setSelect(java.lang.String) method instead.

Parameters:
select - element to add
Returns:
the TopiaQuery

setSelect

public TopiaQuery<E> setSelect(String select)
Set the select in the query. Depends on the result wanted in execute methods.

Parameters:
select - element to set
Returns:
the TopiaQuery

addDistinct

public TopiaQuery<E> addDistinct()
Add the distinct key word in the query. The result will not have multiple same values.

Returns:
the TopiaQuery

addOrder

public TopiaQuery<E> addOrder(String order)
Add an element to the order in the query. Used to add some parameters to order by.

Parameters:
order - element to add
Returns:
the TopiaQuery

addOrderDesc

public TopiaQuery<E> addOrderDesc(String order)

addGroup

public TopiaQuery<E> addGroup(String group)
Add an element to the group of the query. Used to add some paramters to group by.

Parameters:
group - element to add
Returns:
the TopiaQuery

setLimit

public TopiaQuery<E> setLimit(int start,
                              int end)
Limit the result of the query with startIndex and endIndex.

Parameters:
start - first index to get from the results
end - last index to get from the results
Returns:
the TopiaQuery

resetLimit

protected void resetLimit()

setMaxResults

public TopiaQuery<E> setMaxResults(int max)
Set the max results wanted for the query.

Parameters:
max - the number of elements wanted
Returns:
the TopiaQuery

execute

public List execute(TopiaContext transaction)
             throws TopiaException
Simple execution of the query. This method use directly the find method in TopiaContext interface.

Parameters:
transaction - the TopiaContext to use for execution
Returns:
a List of results
Throws:
TopiaException
See Also:
TopiaContext.find(java.lang.String, java.lang.Object[])

execute

public List execute()
             throws TopiaException
DAO must be defined to use this method.

Returns:
a List of results
Throws:
TopiaException
See Also:
execute(org.nuiton.topia.TopiaContext)

executeToEntityList

public List<E> executeToEntityList(TopiaContext transaction)
                                                throws TopiaException,
                                                       ClassCastException
Execute the query and get a List of entity. Some properties will be loaded if they are prealably set using $addLoad(java.lang.String[]).

Parameters:
transaction - the TopiaContext to use for execution
Returns:
a List of TopiaEntity corresponding to the entityClass in argument
Throws:
TopiaException
ClassCastException

executeToEntityList

public List<E> executeToEntityList()
                                                throws TopiaException,
                                                       ClassCastException
DAO must be defined to use this method.

Returns:
a List of TopiaEntity corresponding to the entityClass in argument
Throws:
TopiaException
ClassCastException
See Also:
executeToEntityList(org.nuiton.topia.TopiaContext)

executeToEntityMap

public <K> Map<K,E> executeToEntityMap(TopiaContext transaction,
                                       String keyName,
                                       Class<K> keyClass)
                                                throws TopiaException,
                                                       ClassCastException
Execute the query and get a Map of entity with key type in argument. Some properties will be loaded if they are prealably set using $addLoad(java.lang.String[]).

Type Parameters:
K - the type of the map key
Parameters:
transaction - the TopiaContext to use for execution
keyName - the property name of the key in the entity
keyClass - the key class for the result map
Returns:
a Map with the key type defined and the entity in value
Throws:
TopiaException
ClassCastException

executeToEntityMap

public <K> Map<K,E> executeToEntityMap(String keyName,
                                       Class<K> keyClass)
                                                throws TopiaException,
                                                       ClassCastException
DAO must be defined to use this method.

Type Parameters:
K -
Parameters:
keyName -
keyClass -
Returns:
a Map with the key type defined and the entity in value
Throws:
TopiaException
ClassCastException
See Also:
executeToEntityMap(org.nuiton.topia.TopiaContext, java.lang.String, java.lang.Class)

executeToEntityMap

public Map<String,E> executeToEntityMap(TopiaContext transaction)
                                                     throws TopiaException,
                                                            ClassCastException
Execute the query and get a Map of entity with topiaId in key. Some properties will be loaded if they are prealably set using $addLoad(java.lang.String[]).

Parameters:
transaction - the TopiaContext to use for execution
Returns:
a Map with the key type defined and the entity in value
Throws:
TopiaException
ClassCastException

executeToEntityMap

public Map<String,E> executeToEntityMap()
                                                     throws TopiaException,
                                                            ClassCastException
DAO must be defined to use this method.

Returns:
a Map with the key type defined and the entity in value
Throws:
TopiaException
ClassCastException
See Also:
executeToEntityMap(org.nuiton.topia.TopiaContext)

executeToEntity

public E executeToEntity(TopiaContext transaction)
                                      throws TopiaException,
                                             ClassCastException
Execute the query and get the first result entity. Some properties will be loaded if they are prealably set using $addLoad(java.lang.String[]).

Parameters:
transaction - the TopiaContext to use for execution
Returns:
a TopiaEntity corresponding to the entityClass in argument
Throws:
TopiaException
ClassCastException

executeToEntity

public E executeToEntity()
                                      throws TopiaException,
                                             ClassCastException
DAO must be defined to use this method.

Returns:
a TopiaEntity corresponding to the entityClass in argument
Throws:
TopiaException
ClassCastException
See Also:
executeToEntity(org.nuiton.topia.TopiaContext)

executeToInteger

public int executeToInteger(TopiaContext transaction,
                            String select)
                     throws TopiaException
Execute the query and get an Integer for result. Used for query with COUNT or SUM, ... The select is overriden to get only the right value for return.

Parameters:
transaction - the TopiaContext to use for execution
select - the Select overriden (ex : SUM(myParam))
Returns:
an Integer
Throws:
TopiaException

executeToInteger

public int executeToInteger(String select)
                     throws TopiaException
DAO must be defined to use this method.

Parameters:
select -
Returns:
an Integer
Throws:
TopiaException
See Also:
executeToInteger(org.nuiton.topia.TopiaContext, java.lang.String)

executeToString

public String executeToString(TopiaContext transaction,
                              String select)
                       throws TopiaException
Execute the query and get a String for result. Used for query with MAX, ... The select is overriden to get only the right value for return.

Parameters:
transaction - the TopiaContext to use for execution
select - the Select overriden (ex : MAX(myParam))
Returns:
a String
Throws:
TopiaException

executeToString

public String executeToString(String select)
                       throws TopiaException
DAO must be defined to use this method.

Parameters:
select -
Returns:
a String result
Throws:
TopiaException
See Also:
executeToString(org.nuiton.topia.TopiaContext, java.lang.String)

executeToObject

public Object executeToObject(TopiaContext transaction,
                              String select)
                       throws TopiaException
Execute the query and get an Object for result. The select is overriden to get only the right value for return.

Parameters:
transaction - the TopiaContext to use for execution
select - the Select overriden
Returns:
an Object
Throws:
TopiaException

executeToObject

public Object executeToObject(String select)
                       throws TopiaException
DAO must be defined to use this method.

Parameters:
select -
Returns:
an Object
Throws:
TopiaException
See Also:
executeToObject(org.nuiton.topia.TopiaContext, java.lang.String)

executeCount

public int executeCount(TopiaContext transaction)
                 throws TopiaException
Execute a simple count on the query, i.e. the number of results get from the query.

Parameters:
transaction - the TopiaContext to use for execution
Returns:
an int corresponding to the number of result in the query
Throws:
TopiaException

executeCount

public int executeCount()
                 throws TopiaException
DAO must be defined to use this method.

Returns:
an int corresponding to the number of result in the query
Throws:
TopiaException
See Also:
executeCount(org.nuiton.topia.TopiaContext)

validateDAO

protected boolean validateDAO()
                       throws TopiaException
Throws:
TopiaException

loadProperties

protected <T extends TopiaEntity> void loadProperties(T entity)
                       throws TopiaException
Load all properties for the entity.

Type Parameters:
T - type of the entity extends TopiaEntity
Parameters:
entity - used to load properties
Throws:
TopiaException

loadEntityProperty

protected <T extends TopiaEntity> TopiaEntity loadEntityProperty(T entity,
                                                                 String property)
                                  throws TopiaException
Load a property of type TopiaEntity from an other entity.

Type Parameters:
T - type of the entity extends TopiaEntity
Parameters:
entity - used to load the property
property - name of the property in the entity
Returns:
a TopiaEntity corresponding to the property loaded
Throws:
TopiaException

loadProperty

protected <T extends TopiaEntity> Object loadProperty(T entity,
                                                      String property)
                       throws TopiaException
Load a property from an entity.

Type Parameters:
T - type of the entity extends TopiaEntity
Parameters:
entity - used to load the property
property - name of the property in the entity
Returns:
an Object corresponding to the property loaded
Throws:
TopiaException


Copyright © 2004-2010 CodeLutin. All Rights Reserved.