@Documented
@Inherited
@Retention(value=RUNTIME)
public @interface Query
Expression.
A simple query represented in xml such as this:
<query name="simple">
<query-parameter name="simpleParam1" type="java.lang.String"/>
<compare attribute-name="countryCode" op="equals" parameter="simpleParam1"/>
</query>
can be created by constructing a query structure such as:
@Query(name="simple",
queryParameters = ,
expression = @Expression(
term = @Term(compare = @Compare(attributeName = "countryCode", op="equals", parameter="simpleParam1"))
)
)
Complex queries that use conditional operators need to be constructed using a ConditionalExpression.
A ConditionalExpression allows the operator (AND,OR,NOT) to be used with a number of Term's. To construct
the more complex example below that contains nested conditions:
<query name="AConditionalQuery">
<and>
<has-prefix attribute-name="anAttr" value="val1"/>
<or>
<has-prefix attribute-name="anotherAttr" value="val2"/>
<compare attribute-name="yetAnotherAttr" op="equals" value="val3"/>
</or>
</and>
</query>
A structure such as the one described below would be used. Care should be taken to ensure that the conditional alias's are used correctly.
@Query(name = "AConditionalQuery",
expression = @Expression(
term = @Term(conditionalExpressionAlias = "conditionalAND"),
conditionalExpressions = {
@ConditionalExpression(
alias="conditionalAND",
condition = Condition.and,
terms = {
@Term(hasPrefix = @HasPrefix(attributeName = "anAttr", value="val1")),
@Term(conditionalExpressionAlias = "conditionalOR")
}
),
@ConditionalExpression(
alias="conditionalOR",
condition = Condition.or,
terms = {
@Term(hasPrefix = @HasPrefix(attributeName = "anotherAttr", value="val2")),
@Term(compare = @Compare(attributeName = "yetAnotherAttr", op="equals", value="val3"))
}
)
}
)
| Modifier and Type | Optional Element and Description |
|---|---|
java.lang.String |
description |
Expression |
expression |
java.lang.String |
name |
QueryOptions |
queryOptions |
QueryParameter[] |
queryParameters |
public abstract QueryOptions queryOptions
public abstract QueryParameter[] queryParameters
public abstract Expression expression