|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Filter is used to restrict the results of a query. Filters can be combined and manipulated to create complex queries.
It is important to realize that Filters are just that; they filter the resulting data from the query. For instance, if you have:
query myDataQuery {
do {
select max(article_id) from articles
} map {
articleID = articles.article_id;
}
}
and then add a the filter "lower(title) like 'b%'" the new query will be
select *
from (select max(article_id) from articles) results
where lower(title) like 'b%'
and not
select max(article_id) from articles where lower(title) like 'b%'
This can clearly lead to different results.
However, it is possible to get the query you want by setting the WRAP_QUERIES option to false. You can declare this value within the "options" block of the data query. For example,
query myDataQuery {
options {
WRAP_QUERIES = false;
}
do {
select max(article_id), title from articles
} map {
articleID = articles.article_id;
}
}
It is also important to note that any attribute used within a filter MUST appear within the "map" section of the query definition. This is because the filter must be able to map the attribute name to the correct column and assuming that an attribute name is the same as the column name is not sufficient. So, filtering the above query by the "title" column will error.
Field Summary | |
static String |
FILTER
|
static String |
versionId
|
Method Summary | |
Map |
getBindings()
This returns the bindings for this Filter. |
String |
getConditions()
This returns the string representation of this Filter before any bindings are applied |
Filter |
set(String parameterName,
Object value)
Sets the values of the bind variables in the Filter. |
Field Detail |
public static final String versionId
public static final String FILTER
Method Detail |
public Filter set(String parameterName, Object value)
parameterName
- The name of the bind variablevalue
- The value to substitute in for the bind variable.
this
PersistenceException
- if value type unsupported.public Map getBindings()
public String getConditions()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |