Package org.apache.cayenne.exp
Class FunctionExpressionFactory
java.lang.Object
org.apache.cayenne.exp.FunctionExpressionFactory
public class FunctionExpressionFactory extends Object
Collection of factory methods to create function call expressions.
- Since:
- 4.0
-
Constructor Summary
Constructors Constructor Description FunctionExpressionFactory()
-
Method Summary
Modifier and Type Method Description static Expression
absExp(String path)
static Expression
absExp(Expression exp)
static Expression
avgExp(Expression exp)
static Expression
concatExp(String... paths)
Factory method for expression to call CONCAT(string1, string2, ...) functionstatic Expression
concatExp(Expression... expressions)
Factory method for expression to call CONCAT(string1, string2, ...) functionstatic Expression
countDistinctExp(Expression exp)
static Expression
countExp()
static Expression
countExp(Expression exp)
static Expression
currentDate()
static Expression
currentTime()
static Expression
currentTimestamp()
static Expression
dayOfMonthExp(String path)
static Expression
dayOfMonthExp(Expression exp)
static Expression
dayOfWeekExp(String path)
static Expression
dayOfWeekExp(Expression exp)
static Expression
dayOfYearExp(String path)
static Expression
dayOfYearExp(Expression exp)
static Expression
hourExp(String path)
static Expression
hourExp(Expression exp)
static Expression
lengthExp(String path)
static Expression
lengthExp(Expression exp)
static Expression
locateExp(String substring, String path)
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static Expression
locateExp(String substring, Expression exp)
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static Expression
locateExp(Expression substring, Expression exp)
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static Expression
lowerExp(String path)
static Expression
lowerExp(Expression exp)
static Expression
maxExp(Expression exp)
static Expression
minExp(Expression exp)
static Expression
minuteExp(String path)
static Expression
minuteExp(Expression exp)
static Expression
modExp(String path, Number number)
static Expression
modExp(Expression exp, Number number)
static Expression
modExp(Expression exp, Expression number)
static Expression
monthExp(String path)
static Expression
monthExp(Expression exp)
static Expression
secondExp(String path)
static Expression
secondExp(Expression exp)
static Expression
sqrtExp(String path)
static Expression
sqrtExp(Expression exp)
static Expression
substringExp(String path, int offset, int length)
Call SUBSTRING(string, offset, length) functionstatic Expression
substringExp(Expression exp, int offset, int length)
Call SUBSTRING(string, offset, length) functionstatic Expression
substringExp(Expression exp, Expression offset, Expression length)
Call SUBSTRING(string, offset, length) functionstatic Expression
sumExp(Expression exp)
static Expression
trimExp(String path)
static Expression
trimExp(Expression exp)
static Expression
upperExp(String path)
static Expression
upperExp(Expression exp)
static Expression
weekExp(String path)
static Expression
weekExp(Expression exp)
static Expression
yearExp(String path)
static Expression
yearExp(Expression exp)
-
Constructor Details
-
FunctionExpressionFactory
public FunctionExpressionFactory()
-
-
Method Details
-
substringExp
Call SUBSTRING(string, offset, length) function- Parameters:
exp
- expression that must evaluate to stringoffset
- start offset of substringlength
- length of substring- Returns:
- SUBSTRING() call expression
-
substringExp
Call SUBSTRING(string, offset, length) function- Parameters:
path
- Object path valueoffset
- start offset of substringlength
- length of substring- Returns:
- SUBSTRING() call expression
-
substringExp
Call SUBSTRING(string, offset, length) function- Parameters:
exp
- expression that must evaluate to stringoffset
- start offset of substring must evaluate to intlength
- length of substring must evaluate to int- Returns:
- SUBSTRING() call expression
-
trimExp
- Parameters:
exp
- string expression to trim- Returns:
- TRIM() call expression
-
trimExp
- Parameters:
path
- object path value- Returns:
- TRIM() call expression
-
lowerExp
- Parameters:
exp
- string expression- Returns:
- LOWER() call expression
-
lowerExp
- Parameters:
path
- object path value- Returns:
- LOWER() call expression
-
upperExp
- Parameters:
exp
- string expression- Returns:
- UPPER() call expression
-
upperExp
- Parameters:
path
- object path value- Returns:
- UPPER() call expression
-
lengthExp
- Parameters:
exp
- string expression- Returns:
- LENGTH() call expression
-
lengthExp
- Parameters:
path
- object path value- Returns:
- LENGTH() call expression
-
locateExp
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.- Parameters:
substring
- object path valueexp
- string expression- Returns:
- LOCATE() call expression
-
locateExp
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.- Parameters:
substring
- object path valuepath
- object path- Returns:
- LOCATE() call expression
-
locateExp
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.- Parameters:
substring
- string expressionexp
- string expression- Returns:
- LOCATE() call expression
-
absExp
- Parameters:
exp
- numeric expression- Returns:
- ABS() call expression
-
absExp
- Parameters:
path
- object path value- Returns:
- ABS() call expression
-
sqrtExp
- Parameters:
exp
- numeric expression- Returns:
- SQRT() call expression
-
sqrtExp
- Parameters:
path
- object path value- Returns:
- SQRT() call expression
-
modExp
- Parameters:
exp
- numeric expressionnumber
- divisor- Returns:
- MOD() call expression
-
modExp
- Parameters:
path
- object path valuenumber
- divisor- Returns:
- MOD() call expression
-
modExp
- Parameters:
exp
- object path valuenumber
- numeric expression- Returns:
- MOD() call expression
-
concatExp
Factory method for expression to call CONCAT(string1, string2, ...) function
Can be used like:
Expression concat = concatExp(SomeClass.POPERTY_1.getPath(), SomeClass.PROPERTY_2.getPath());
SQL generation note:
- if DB supports CONCAT function with vararg then it will be used
- if DB supports CONCAT function with two args but also supports concat operator, then operator (eg ||) will be used
- if DB supports only CONCAT function with two args then it will be used what can lead to SQL exception if used with more than two arguments
Currently only known DB with limited concatenation functionality is Openbase.
- Parameters:
expressions
- array of expressions- Returns:
- CONCAT() call expression
-
concatExp
Factory method for expression to call CONCAT(string1, string2, ...) function
Can be used like:
Expression concat = concatExp("property1", "property2");
SQL generation note:
- if DB supports CONCAT function with vararg then it will be used
- if DB supports CONCAT function with two args but also supports concat operator, then operator (eg ||) will be used
- if DB supports only CONCAT function with two args then it will be used what can lead to SQL exception if used with more than two arguments
Currently only Openbase DB has limited concatenation functionality.
- Parameters:
paths
- array of paths- Returns:
- CONCAT() call expression
-
countExp
- Returns:
- Expression COUNT(*)
-
countExp
- Returns:
- Expression COUNT(exp)
-
countDistinctExp
- Returns:
- Expression COUNT(DISTINCT(exp))
- Since:
- 4.1
-
minExp
- Returns:
- Expression MIN(exp)
-
maxExp
- Returns:
- Expression MAX(exp)
-
avgExp
- Returns:
- Expression AVG(exp)
-
sumExp
- Returns:
- SUM(exp) expression
-
currentDate
- Returns:
- CURRENT_DATE expression
-
currentTime
- Returns:
- CURRENT_TIME expression
-
currentTimestamp
- Returns:
- CURRENT_TIMESTAMP expression
-
yearExp
- Parameters:
exp
- date/timestamp expression- Returns:
- year(exp) function expression
-
yearExp
- Parameters:
path
- String path- Returns:
- year(path) function expression
-
monthExp
- Parameters:
exp
- date/timestamp expression- Returns:
- month(exp) function expression
-
monthExp
- Parameters:
path
- String path- Returns:
- month(path) function expression
-
weekExp
- Parameters:
exp
- date/timestamp expression- Returns:
- week(exp) function expression
-
weekExp
- Parameters:
path
- String path- Returns:
- week(path) function expression
-
dayOfYearExp
- Parameters:
exp
- date/timestamp expression- Returns:
- dayOfYear(exp) function expression
-
dayOfYearExp
- Parameters:
path
- String path- Returns:
- dayOfYear(path) function expression
-
dayOfMonthExp
- Parameters:
exp
- date/timestamp expression- Returns:
- dayOfMonth(exp) function expression, synonym for day()
-
dayOfMonthExp
- Parameters:
path
- String path- Returns:
- dayOfMonth(path) function expression, synonym for day()
-
dayOfWeekExp
- Parameters:
exp
- date/timestamp expression- Returns:
- dayOfWeek(exp) function expression
-
dayOfWeekExp
- Parameters:
path
- String path- Returns:
- dayOfWeek(path) function expression
-
hourExp
- Parameters:
exp
- date/timestamp expression- Returns:
- hour(exp) function expression
-
hourExp
- Parameters:
path
- String path- Returns:
- hour(path) function expression
-
minuteExp
- Parameters:
exp
- date/timestamp expression- Returns:
- minute(exp) function expression
-
minuteExp
- Parameters:
path
- String path- Returns:
- minute(path) function expression
-
secondExp
- Parameters:
exp
- date/timestamp expression- Returns:
- second(exp) function expression
-
secondExp
- Parameters:
path
- String path- Returns:
- second(path) function expression
-