TopiaQuery
will be removed in version 3.0@Deprecated public class TopiaQuery extends Object
TopiaContext.findAll(String,
Object...)
.
TODO-FD20091224 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 usingCreated: 21 déc. 2009TopiaContext.findAll(String, 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 usingTopiaContext.findAll(String, Object...)
: TopiaContext context = rootContext.beginTransaction(); String query = "FROM " + Person.class.getName(); List<Object> params = new ArrayList<>(); String separator = " WHERE "; // company parameter can be null if (company != null) { query += separator + "company = :company"; params.add("company"); params.add(company); separator = " AND "; } // contact paramater can be null if (contact != null) { query += separator + "contact = :contact"; params.add("contact"); params.add(contact); separator = " AND "; } context.findAll(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 (these different queries are equivalent) : 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); 4- query.addNullOr("P.company", Op.EQ, company). add("P.firstName", Op.LIKE, firstName + "%"); You can use TopiaQuery to create a subquery in an other TopiaQuery, you have to use the methodfullQuery()
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 asTopiaContext.findAll(String, 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 methodaddLoad(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<Contact> : 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")
Modifier and Type | Class and Description |
---|---|
static class |
TopiaQuery.Op
Deprecated.
Enum to simmplify using operation in query.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
distinct
Deprecated.
|
protected Integer |
endIndex
Deprecated.
|
protected StringBuilder |
from
Deprecated.
From part of the query.
|
static String |
FROM_SEPARATOR_DEFAULT
Deprecated.
|
static String |
FROM_SEPARATOR_JOIN
Deprecated.
|
static String |
FROM_SEPARATOR_LEFT_JOIN
Deprecated.
|
protected List<String> |
groupBys
Deprecated.
To keep GROUP BY part of the query filled by user.
|
protected String |
mainAlias
Deprecated.
|
protected List<String> |
orderBys
Deprecated.
To keep ORDER BY part of the query filled by user.
|
protected List<Object> |
params
Deprecated.
Params for HQL query.
|
protected List<String> |
propertiesToLoad
Deprecated.
|
protected Integer |
startIndex
Deprecated.
|
protected List<String> |
userSelects
Deprecated.
To keep SELECT part of the query filled by user.
|
protected List<String> |
wheres
Deprecated.
To keep WHERE part of the query filled by user.
|
Constructor and Description |
---|
TopiaQuery()
Deprecated.
|
TopiaQuery(Class<? extends TopiaEntity> mainEntityClass)
Deprecated.
Create a TopiaQuery based on the
entityClass . |
TopiaQuery(Class<? extends TopiaEntity> mainEntityClass,
String alias)
Deprecated.
Create a TopiaQuery based on the
entityClass . |
Modifier and Type | Method and Description |
---|---|
TopiaQuery |
add(Map<String,Object> properties)
Deprecated.
since 2.3.4 use
addEquals(Map) |
TopiaQuery |
add(String where)
Deprecated.
since 2.3.4, use
addWhere(String) instead |
TopiaQuery |
add(String paramName,
Object... paramValue)
Deprecated.
since 2.3.4, use
addEquals(String, Object...) instead |
TopiaQuery |
add(String paramName,
TopiaQuery.Op constraint,
Object paramValue)
Deprecated.
since 2.3.4, use
addWhere(String, Op, Object) instead |
TopiaQuery |
addBetween(String paramName,
Object value1,
Object value2)
Deprecated.
Add an element with BETWEEN operation.
|
TopiaQuery |
addDistinct()
Deprecated.
Add the distinct key word in the query.
|
TopiaQuery |
addEquals(Map<String,Object> properties)
Deprecated.
Add a map of properties to the where clause of the query.
|
TopiaQuery |
addEquals(String paramName,
Object... paramValue)
Deprecated.
Add an element to the query.
|
TopiaQuery |
addFetch(String... properties)
Deprecated.
Used to load properties during query execution using FETCH keyword.
|
TopiaQuery |
addFilter(EntityFilter filter)
Deprecated.
Add a
filter to the query that contains limit indexes,
orderBy condition and referenceId if needed. |
TopiaQuery |
addFilter(EntityFilter filter,
String propertyToFilter)
Deprecated.
Add a
filter to the query that contains limit indexes,
orderBy condition and referenceId if needed. |
TopiaQuery |
addFrom(Class<? extends TopiaEntity> entityClass)
Deprecated.
Add an other entity type to the from in the query.
|
TopiaQuery |
addFrom(Class<? extends TopiaEntity> entityClass,
String alias)
Deprecated.
Add an other entity type to the from in the query with an alias.
|
TopiaQuery |
addFrom(String str)
Deprecated.
since 2.3.4 use correct addFrom or addJoin or addLeftJoin
|
protected TopiaQuery |
addFrom(String separator,
String property,
String alias)
Deprecated.
Add an element to the from in the query.
|
protected TopiaQuery |
addFromJoin(String separator,
String property,
String alias,
boolean fetch)
Deprecated.
|
TopiaQuery |
addGroup(String... group)
Deprecated.
Add an element to the group of the query.
|
TopiaQuery |
addInElements(String elementProperty,
String containerProperty)
Deprecated.
Add link constraint between two properties.
|
TopiaQuery |
addJoin(String property,
String alias,
boolean fetch)
Deprecated.
Add a inner join
property to the query with alias . |
TopiaQuery |
addLeftJoin(String property,
String alias,
boolean fetch)
Deprecated.
Add a left join
property to the query with alias . |
TopiaQuery |
addLoad(String... properties)
Deprecated.
Add a property to load when query is executed.
|
TopiaQuery |
addNotNull(String paramName)
Deprecated.
Add an element to the query with the constraint Not null.
|
TopiaQuery |
addNull(String paramName)
Deprecated.
Add an element to the query with the constraint null.
|
TopiaQuery |
addNullOr(String paramName,
TopiaQuery.Op constraint,
Object paramValue)
Deprecated.
Add an element to the query.
|
TopiaQuery |
addOrder(String... order)
Deprecated.
Add an element to the order in the query.
|
TopiaQuery |
addOrderDesc(String order)
Deprecated.
|
TopiaQuery |
addParam(String id,
Object paramValue)
Deprecated.
Add a HQL parameter to the Query.
|
TopiaQuery |
addParams(List<Object> params)
Deprecated.
Add muliple paramaters to the Query.
|
TopiaQuery |
addSelect(String... select)
Deprecated.
Add an element to the select in the query.
|
TopiaQuery |
addSubQuery(String queryPart,
TopiaQuery subquery)
Deprecated.
Method used to add a subquery in an existing query.
|
TopiaQuery |
addWhere(String where)
Deprecated.
Add a where element to the Query.
|
TopiaQuery |
addWhere(String paramName,
TopiaQuery.Op operator,
Object paramValue)
Deprecated.
Add an element to the query.
|
List |
execute(TopiaContext transaction)
Deprecated.
Simple execution of the query.
|
int |
executeCount(TopiaContext transaction)
Deprecated.
Execute a simple count on the query, i.e. the number of results get from
the query.
|
<E extends TopiaEntity> |
executeToEntity(TopiaContext transaction,
Class<E> entityClass)
Deprecated.
Execute the query and get the first result entity.
|
<E extends TopiaEntity> |
executeToEntityList(TopiaContext transaction,
Class<E> entityClass)
Deprecated.
Execute the query and get a List of entity.
|
<E extends TopiaEntity> |
executeToEntityMap(TopiaContext transaction,
Class<E> entityClass)
Deprecated.
Execute the query and get a Map of entity with topiaId in key.
|
<E extends TopiaEntity,K> |
executeToEntityMap(TopiaContext transaction,
Class<E> entityClass,
String keyName,
Class<K> keyClass)
Deprecated.
Execute the query and get a Map of entity with key type in argument.
|
int |
executeToInteger(TopiaContext transaction,
String select)
Deprecated.
Execute the query and get an Integer for result.
|
Object |
executeToObject(TopiaContext transaction,
String select)
Deprecated.
Execute the query and get an Object for result.
|
String |
executeToString(TopiaContext transaction,
String select)
Deprecated.
Execute the query and get a String for result.
|
protected void |
finalize()
Deprecated.
|
String |
fullQuery()
Deprecated.
Get the full query.
|
String |
getMainAlias()
Deprecated.
Return the mainAlias set from constructor.
|
List<Object> |
getParams()
Deprecated.
|
protected List<String> |
getPropertiesToLoad()
Deprecated.
|
static String |
getProperty(String... entityProperty)
Deprecated.
This method is used to concat properties from entities.
|
String |
getPropertyCreateDate(String alias)
Deprecated.
|
String |
getPropertyId(String alias)
Deprecated.
|
String |
getPropertyVersion(String alias)
Deprecated.
|
protected String |
getValueName(String paramName)
Deprecated.
|
protected boolean |
isUserSelectEqualsMainAlias()
Deprecated.
|
protected <T extends TopiaEntity> |
loadEntityProperty(T entity,
String property)
Deprecated.
Load a property of type TopiaEntity from an other entity.
|
protected void |
loadProperties(TopiaEntity entity)
Deprecated.
Load all properties for the entity.
|
protected <T extends TopiaEntity> |
loadProperty(T entity,
String property)
Deprecated.
Load a property from an entity.
|
TopiaQuery |
resetLimit()
Deprecated.
Remove limits previously set
|
TopiaQuery |
setFrom(Class<? extends TopiaEntity> mainEntityClass)
Deprecated.
Set the mainEntity in the from part of the query.
|
TopiaQuery |
setFrom(Class<? extends TopiaEntity> mainEntityClass,
String alias)
Deprecated.
Set the mainEntity in the from part of the query and use an alias for
this mainEntity.
|
TopiaQuery |
setLimit(int start,
int end)
Deprecated.
Limit the result of the query with startIndex and endIndex.
|
TopiaQuery |
setMaxResults(int max)
Deprecated.
Set the max results wanted for the query.
|
TopiaQuery |
setSelect(String... select)
Deprecated.
Set the select in the query.
|
String |
toString()
Deprecated.
|
public static final String FROM_SEPARATOR_DEFAULT
public static final String FROM_SEPARATOR_JOIN
public static final String FROM_SEPARATOR_LEFT_JOIN
protected List<String> userSelects
protected List<String> groupBys
protected List<String> orderBys
protected List<String> wheres
protected boolean distinct
protected StringBuilder from
protected Integer startIndex
protected Integer endIndex
protected String mainAlias
public TopiaQuery()
public TopiaQuery(Class<? extends TopiaEntity> mainEntityClass)
entityClass
. The from statement
is automatically set.mainEntityClass
- used as from part of the querypublic TopiaQuery(Class<? extends TopiaEntity> mainEntityClass, String alias)
entityClass
. The from statement
is automatically set, the select statement must be necessary in some
case, the query will manage this case using the mainAlias by default.mainEntityClass
- used as from part of the queryalias
- for the mainEntityClasspublic TopiaQuery setFrom(Class<? extends TopiaEntity> mainEntityClass)
mainEntityClass
- type of the mainEntitypublic TopiaQuery setFrom(Class<? extends TopiaEntity> mainEntityClass, String alias)
mainEntityClass
- type of the mainEntityalias
- for the entity in the query@Deprecated public TopiaQuery addFrom(String str)
str
- the element to addaddFrom(Class, String)
,
addJoin(String, String, boolean)
,
addLeftJoin(String, String, boolean)
protected TopiaQuery addFrom(String separator, String property, String alias)
separator
.property
- the property to addalias
- alias of the property to add in form part of the queryseparator
- The separator to use before adding the element (if null
the FROM_SEPARATOR_DEFAULT
will be used).public TopiaQuery addJoin(String property, String alias, boolean fetch)
property
to the query with alias
.
The join is done in From statement as : FROM Contact C JOIN C.boat B. The
added part is 'JOIN C.boat B' using addJoin("C.boat", "B", false). The order
of calling addFrom(Class, String)
or this method is very important.
The first element in the FROM is always the main entity of the query.property
- Property name to use as a Joinalias
- Alias of the property in the queryfetch
- Add FETCH keyword to load the property in result (avoid
lazy initialization)public TopiaQuery addLeftJoin(String property, String alias, boolean fetch)
property
to the query with alias
.
The join is done in From statement as : FROM Contact C LEFT JOIN C.boat B.
The added part is 'LEFT JOIN C.boat B' using addJoin("C.boat", "B", false).
The order of calling addFrom(Class, String)
or this method is
very important. The first element in the FROM is always the main entity
of the query.property
- Property name to use as a Joinalias
- Alias of the property in the queryfetch
- Add FETCH keyword to load the property in result (avoid
lazy initialization)protected TopiaQuery addFromJoin(String separator, String property, String alias, boolean fetch)
public TopiaQuery addFrom(Class<? extends TopiaEntity> entityClass)
entityClass
- different from the mainEntitypublic TopiaQuery addFrom(Class<? extends TopiaEntity> entityClass, String alias)
entityClass
- different from the mainEntityalias
- of the entity in the querypublic String fullQuery()
public TopiaQuery addParam(String id, Object paramValue)
id
- identification of the param in the queryparamValue
- value of the parampublic TopiaQuery addParams(List<Object> params)
params
- a list of HQL params with key and value in order.getValueName(String)
public String getMainAlias()
public TopiaQuery addLoad(String... properties)
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();
properties
- List of properties to loadpublic TopiaQuery addFetch(String... properties)
addLoad(String...)
or load manually the entities
wanted.properties
- Properties to load during query execution@Deprecated public TopiaQuery add(String where)
addWhere(String)
insteadwhere
- Where statement to addpublic TopiaQuery addWhere(String where)
where
- element to add@Deprecated public TopiaQuery add(String paramName, TopiaQuery.Op constraint, Object paramValue)
addWhere(String, Op, Object)
insteadparamName
- name of the parameter to addconstraint
- constraint to useparamValue
- value of this parameterpublic TopiaQuery addWhere(String paramName, TopiaQuery.Op operator, Object paramValue)
operator
is needed to determine what type of operation it is.
Ex : add("boat", Op.EQ, boat) means -> boat = :boat. Also if the paramValue
is Null, the paramName will be added to the query with the constraint
null (IS NULL).
TODO-fdesbois-2010-05-26 : maybe manage more than one paramValue with Object... Depends on operatorparamName
- the name of the parameter in the query (attribute of
the entity)operator
- the operation concernedparamValue
- the value of the parameter (an other entity, a String,
...)@Deprecated public TopiaQuery add(String paramName, Object... paramValue)
addEquals(String, Object...)
insteadparamName
- name of the parameter to addparamValue
- value of this parameterpublic TopiaQuery addEquals(String paramName, Object... paramValue)
paramValue
list (except if it's the only one value, it's ambiguous).
Note : this method do nothing if the paramValue
is not defined.
You can also set paramValue
to null if you want the paramName
to be null in the query.paramName
- name of the parameter in the queryparamValue
- values of the parameteraddWhere(String, Op, Object)
@Deprecated public TopiaQuery add(Map<String,Object> properties)
addEquals(Map)
properties
- map of the properties to addpublic TopiaQuery addEquals(Map<String,Object> properties)
properties
- to add to the querypublic TopiaQuery addNotNull(String paramName)
paramName
- name of the parameter in the querypublic TopiaQuery addNullOr(String paramName, TopiaQuery.Op constraint, Object paramValue)
paramName
- the name of the parameter in the query (attribute of
the entity)constraint
- the operation concerned by the orparamValue
- the value of the parameter (an other entity, a String,
...)public TopiaQuery addNull(String paramName)
paramName
- name of the parameter in the querypublic TopiaQuery addBetween(String paramName, Object value1, Object value2)
paramName
will be
found between value1
and value2
. Useful for date
manipulations.paramName
- The name of the parameter in the query (entity property)value1
- First valuevalue2
- Second valuepublic TopiaQuery addInElements(String elementProperty, String containerProperty)
elementProperty
is in
elements of containerProperty
which is a collection with same type
than elementProperty
. (HQL : elementProperty IN elements
(containerProperty))elementProperty
- contains in containerProperty collectioncontainerProperty
- collection which contains elementPropertypublic TopiaQuery addSubQuery(String queryPart, TopiaQuery subquery)
subquery
in WHERE part of the
query. The queryPart
is the element in the query to bind with the
subquery
. The ? character is used to inject the subquery into the
queryPart
. Ex :
// Add a SUB_ELMT = (subquery) into the query query.addSubQuery("SUB_ELMT = (?)", subquery, false);
queryPart
- part of the query where subquery need to be injectedsubquery
- existing topiaQuery as subquerygetValueName(String)
public TopiaQuery addSelect(String... select)
setSelect(String...)
method instead.select
- element to addpublic TopiaQuery setSelect(String... select)
select
- element to setpublic TopiaQuery addDistinct()
public TopiaQuery addOrder(String... order)
order
- element to addpublic TopiaQuery addOrderDesc(String order)
public TopiaQuery addGroup(String... group)
group
- element to addpublic TopiaQuery setLimit(int start, int end)
start
- first index to get from the resultsend
- last index to get from the resultspublic TopiaQuery resetLimit()
public TopiaQuery setMaxResults(int max)
max
- the number of elements wantedpublic TopiaQuery addFilter(EntityFilter filter) throws IllegalArgumentException
filter
to the query that contains limit indexes,
orderBy condition and referenceId if needed. The referenceProperty is
necessary to use the referenceId of the filter
. The filter will
be applied on the main entity in the query (using the mainAlias if
necessary).
Note : the default orderBy is the topiaCreateDate ordered desc (the most
recent in first)filter
- Filter to apply on the queryIllegalArgumentException
- if referenceId is defined but no
referenceProperty was setaddFilter(EntityFilter, String)
public TopiaQuery addFilter(EntityFilter filter, String propertyToFilter) throws IllegalArgumentException
filter
to the query that contains limit indexes,
orderBy condition and referenceId if needed. In some case it's necessary
to specify explicitely the propertyToFilter
in complex queries.
The referenceProperty need to be specifie in filter
to have a
correspondance between the referenceId and it's property in the query. By
default, the propertyToFilter
is the mainAlias of the query.
Note : the default orderBy is the topiaCreateDate ordered desc (the most
recent in first)filter
- Filter to apply on the querypropertyToFilter
- Explicit property to filterIllegalArgumentException
- if referenceId is defined but no
referenceProperty was setpublic List execute(TopiaContext transaction) throws TopiaException
transaction
- the TopiaContext to use for executionTopiaException
- for error on query executionTopiaContext.findAll(String, Object...)
public <E extends TopiaEntity> List<E> executeToEntityList(TopiaContext transaction, Class<E> entityClass) throws TopiaException, ClassCastException
addLoad(String...)
.E
- entity typetransaction
- the TopiaContext to use for executionentityClass
- used to check return type of execution resultsTopiaException
- for error on query executionClassCastException
- if entityClass doesn't match to resultspublic <E extends TopiaEntity,K> Map<K,E> executeToEntityMap(TopiaContext transaction, Class<E> entityClass, String keyName, Class<K> keyClass) throws TopiaException, ClassCastException
addLoad(String...)
.E
- entity typeK
- the type of the map keytransaction
- the TopiaContext to use for executionentityClass
- needed to execute the querykeyName
- the property name of the key in the entitykeyClass
- the key class for the result mapTopiaException
- for error on query executionClassCastException
- if entityClass doesn't match to resultspublic <E extends TopiaEntity> Map<String,E> executeToEntityMap(TopiaContext transaction, Class<E> entityClass) throws TopiaException, ClassCastException
addLoad(String...)
.E
- entity typetransaction
- the TopiaContext to use for executionentityClass
- used to check return type of execution resultsTopiaException
- for error on query executionClassCastException
- if entityClass doesn't match to resultspublic <E extends TopiaEntity> E executeToEntity(TopiaContext transaction, Class<E> entityClass) throws TopiaException, ClassCastException
addLoad(String...)
.E
- entity typetransaction
- the TopiaContext to use for executionentityClass
- used to check return type of execution resultsTopiaException
- for error on query executionClassCastException
- if entityClass doesn't match to resultspublic Object executeToObject(TopiaContext transaction, String select) throws TopiaException
transaction
- the TopiaContext to use for executionselect
- the Select overridenTopiaException
- for error on query executionpublic int executeToInteger(TopiaContext transaction, String select) throws TopiaException
transaction
- the TopiaContext to use for executionselect
- the Select overriden (ex : SUM(myParam))TopiaException
- for error on query executionpublic String executeToString(TopiaContext transaction, String select) throws TopiaException
transaction
- the TopiaContext to use for executionselect
- the Select overriden (ex : MAX(myParam))TopiaException
- for error on query executionpublic int executeCount(TopiaContext transaction) throws TopiaException
COUNT(DISTINCT mainAlias)
transaction
- the TopiaContext to use for executionTopiaException
- for error on query executionprotected boolean isUserSelectEqualsMainAlias()
protected void loadProperties(TopiaEntity entity) throws TopiaException
entity
- used to load propertiesTopiaException
- for error on query executionprotected <T extends TopiaEntity> TopiaEntity loadEntityProperty(T entity, String property) throws TopiaException
T
- type of the entity extends TopiaEntityentity
- used to load the propertyproperty
- name of the property in the entityTopiaException
- for error on query executionprotected <T extends TopiaEntity> Object loadProperty(T entity, String property) throws TopiaException
T
- type of the entity extends TopiaEntityentity
- used to load the propertyproperty
- name of the property in the entityTopiaException
- for error loading property (encapsulate
IllegalACessException, InvocationTargetException,
NoSuchMethodException)public static String getProperty(String... entityProperty)
getProperty("boat", Boat.SHIP_OWNER, ShipOwner.NAME); // will return boat.shipOwner.nameIt's better to use constants instead of directly the string chain to avoid problems on changing property name in model. Furthermore it's better to use this method instead of doing :
"boat." + Boat.SHIP_OWNER + "." + ShipOwner.NAME
entityProperty
- to concatprotected void finalize() throws Throwable
Copyright © 2004–2022 Code Lutin. All rights reserved.