org.sormula.annotation
Annotation Type WhereField


@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface WhereField

Defines a field within a Where annotation.

Since:
1.0
Author:
Jeff Miller

Required Element Summary
 java.lang.String name
          Name of row member involved in where condition.
 
Optional Element Summary
 java.lang.String booleanOperator
          SQL boolean operator to use preceding this field.
 java.lang.String comparisonOperator
          SQL comparison operator to use in condition "column-name comparisonOperator ?".
 java.lang.String operand
          SQL to use as operand following comparison operator.
 

Element Detail

name

public abstract java.lang.String name
Name of row member involved in where condition.

Returns:
field name to use

booleanOperator

public abstract java.lang.String booleanOperator
SQL boolean operator to use preceding this field. Possible operators are "AND", "OR", "AND NOT", "OR NOT", "NOT", etc. Operator has no affect for first field in where condition.

Returns:
Boolean opearator to be used before "column-name booleanOperator ?"
Default:
"AND"

comparisonOperator

public abstract java.lang.String comparisonOperator
SQL comparison operator to use in condition "column-name comparisonOperator ?". Example operators are: "=", "<", "<=", ">", ">=", "LIKE", "<>", "IN", "NOT IN". For "IS NULL" use operator="IS" and operand="NULL".

When comparison operator is "IN" then the condition used is "column-name IN (?, ?, ...)" and the corresponding parameter supplied by SqlOperation.setParameters(Object...) may be a Collection. The number of ? parameter placeholders within the parentheses will be equal to the size of the collection.

Any SqlOperation that uses a WhereField with a comparison operator of "IN" will be prepared each time it is executed, SqlOperation.execute() since the number of parameters within the IN phrase may be different from previous execution.

"IN" operator may be used with with other operators within the same Where annotation. Multiple "IN" operators may be used within same Where annotation.

Returns:
sql comparison operator to use between column name and parameter
Default:
"="

operand

public abstract java.lang.String operand
SQL to use as operand following comparison operator. Operand will be appended to SQL following the comparison operator. Operand will be used "as is" and must be valid SQL. An operand of "?" is used to indicate that the parameter will be supplied at runtime.

Operand can be a constant, for example:
@Where(name="hasInventory", whereFields=@WhereField(name="quantity", comparisonOperator=">", operand="0"))

If operand is "?", then the parameter for the field will be obtained from row object as set with ScalarSelectOperation.setRowParameters(Object) or parameter set with SqlOperation.setParameters(Object...).

Returns:
SQL operand to use as where parameter
Since:
1.4
Default:
"?"