@Status(stage=TEST, unitTests=COMPLETE) @Review(by="Kees Schotanus", at="2009-10-08", reason="After creation of unit tests") public class WhereClause extends Object
final WhereClause whereClause = new WhereClause();
whereClause.addRelationalExpression("e.id", RelationalOperator.EQUAL, getNumber());
whereClause.addRelationalExpression("e.symbol", RelationalOperator.EQUAL, getSymbol());
whereClause.addStartsWith("e.name", getName());
whereClause.addBetween("e.weight", getFromWeight(), getToWeight());
e.id=?1 AND e.symbol=?2 AND e.name LIKE ?3 AND e.weight BETWEEN ?4 AND ?5
getParameters()
you can get all the parameters that need to be inserted into the where clause.Constructor and Description |
---|
WhereClause() |
Modifier and Type | Method and Description |
---|---|
void |
addAndExpression(String leftOperand,
String rightOperand)
Adds a boolean AND expression to this WhereClause that is created from the supplied leftOperand and rightOperand.
|
void |
addAsIs(String expression)
Adds the supplied expression as-is to this WhereClause.
|
void |
addBetween(String column,
Object minimum,
Object maximum)
Adds a BETWEEN expression to this WhereClause that is created from the supplied column and minimum and maximum values.
|
void |
addEndsWith(String column,
String value)
Adds a LIKE expression (where the percent sign is at the beginning of the expression) to this WhereClause that is
created from the supplied column and value.
|
void |
addExpression(String expression)
Adds the supplied expression to this WhereClause.
|
static String |
addFunctionCall(SingleParamFunction function,
String expression)
Creates a function call from the supplied function and parameter.
|
void |
addIsNotNull(String column)
Adds an IS NOT NULL expression to this WhereClause that is created from the supplied column.
|
void |
addIsNull(String column)
Adds an IS NULL expression to this WhereClause that is created from the supplied column.
|
void |
addOrExpression(String leftOperand,
String rightOperand)
Adds a boolean OR expression to this WhereClause that is created from the supplied leftOperand and rightOperand.
|
void |
addRelationalExpression(String column,
RelationalOperator operator,
Object value)
Adds a relational expression to this WhereClause that is created from the supplied column, operator and value.
|
void |
addStartsWith(String column,
String value)
Adds a LIKE expression (where the percent sign is at the end of the expression) to this WhereClause that is created from
the supplied column and value.
|
List<Object> |
getParameters()
Gets all the JP/QL parameters.
|
String |
toString()
Creates a String representation of this WhereClause.
|
public void addAsIs(String expression)
expression
- The expression to add as-is to this WhereClause.public void addExpression(String expression)
expression
- The expression to add to this WhereClause.public void addAndExpression(String leftOperand, String rightOperand)
leftOperand
- The operand to the left of the AND.rightOperand
- The operand to the right of the AND.IllegalArgumentException
- When either the supplied leftOperand or rightOperand is empty.NullPointerException
- When either the supplied leftOperand or rightOperand is null.public void addOrExpression(String leftOperand, String rightOperand)
leftOperand
- The operand to the left of the OR.rightOperand
- The operand to the right of the OR.IllegalArgumentException
- When either the supplied leftOperand or rightOperand is empty.NullPointerException
- When either the supplied leftOperand or rightOperand is null.public void addRelationalExpression(String column, RelationalOperator operator, Object value)
column
- The column.operator
- The relational operator to apply.value
- The value.IllegalArgumentException
- When the supplied column is empty.NullPointerException
- When either the supplied column or operator is null.public void addStartsWith(String column, String value)
column
- The column.value
- The value.IllegalArgumentException
- When the supplied column is empty.NullPointerException
- When the supplied column is null.public void addEndsWith(String column, String value)
column
- The column.value
- The value.IllegalArgumentException
- When the supplied column is empty.NullPointerException
- When the supplied column is null.public void addBetween(String column, Object minimum, Object maximum)
column
- The column.minimum
- The minimum value.maximum
- The maximum value.IllegalArgumentException
- When the supplied column is empty.NullPointerException
- When the supplied column is null.public void addIsNull(String column)
column
- The column.IllegalArgumentException
- When the supplied column is empty.NullPointerException
- When the supplied column is null.public void addIsNotNull(String column)
column
- The column.IllegalArgumentException
- When the supplied column is empty.NullPointerException
- When the supplied column is null.public static String addFunctionCall(SingleParamFunction function, String expression)
function
- The function to call.expression
- The expression that is the parameter to the function.IllegalArgumentException
- When either the supplied function or expression is empty.NullPointerException
- When either the supplied function or expression is null.public String toString()
Copyright © 2008–2018. All rights reserved.