Package org.apache.cayenne.exp
Class FunctionExpressionFactory
java.lang.Object
org.apache.cayenne.exp.FunctionExpressionFactory
Collection of factory methods to create function call expressions.
- Since:
- 4.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Expression
static Expression
absExp
(Expression exp) static Expression
avgExp
(Expression exp) static Expression
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
static Expression
countExp()
static Expression
countExp
(Expression exp) static Expression
static Expression
static Expression
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
functionCall
(String function, Object... args) static Expression
static Expression
hourExp
(Expression exp) static Expression
static Expression
lengthExp
(Expression exp) static Expression
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
static Expression
lowerExp
(Expression exp) static Expression
maxExp
(Expression exp) static Expression
minExp
(Expression exp) static Expression
static Expression
minuteExp
(Expression exp) static Expression
static Expression
modExp
(Expression exp, Number number) static Expression
modExp
(Expression exp, Expression number) static Expression
static Expression
monthExp
(Expression exp) static Expression
static Expression
static Expression
secondExp
(Expression exp) static Expression
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
static Expression
trimExp
(Expression exp) static Expression
static Expression
upperExp
(Expression exp) static Expression
static Expression
weekExp
(Expression exp) static Expression
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
-
functionCall
- Parameters:
function
- name to callargs
- function arguments- Returns:
- expression to call "function" with provided arguments
- Since:
- 4.2
-
operator
- Parameters:
operator
- to callargs
- arguments- Returns:
- expression to use custom "operator" with provided arguments
- Since:
- 4.2
-