com.arsdigita.persistence
Interface Filter

All Known Subinterfaces:
CompoundFilter

public interface Filter

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.

Version:
$Revision: #8 $ $Date: 2004/04/07 $
Author:
rhs@mit.edu, randyg@alum.mit.edu

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

versionId

public static final String versionId
See Also:
Constant Field Values

FILTER

public static final String FILTER
See Also:
Constant Field Values
Method Detail

set

public Filter set(String parameterName,
                  Object value)
Sets the values of the bind variables in the Filter.

Parameters:
parameterName - The name of the bind variable
value - The value to substitute in for the bind variable.
Returns:
returns this
Throws:
PersistenceException - if value type unsupported.

getBindings

public Map getBindings()
This returns the bindings for this Filter. That is, it returns a map of key (variable name) - value (variable value) pairs

Returns:
a map of key (variable name) - value (variable value) pairs

getConditions

public String getConditions()
This returns the string representation of this Filter before any bindings are applied



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC