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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Expressionstatic ExpressionabsExp(Expression exp) static ExpressionavgExp(Expression exp) static ExpressionFactory method for expression to call CONCAT(string1, string2, ...) functionstatic ExpressionconcatExp(Expression... expressions) Factory method for expression to call CONCAT(string1, string2, ...) functionstatic Expressionstatic ExpressioncountExp()static ExpressioncountExp(Expression exp) static Expressionstatic Expressionstatic Expressionstatic ExpressiondayOfMonthExp(String path) static ExpressiondayOfMonthExp(Expression exp) static ExpressiondayOfWeekExp(String path) static ExpressiondayOfWeekExp(Expression exp) static ExpressiondayOfYearExp(String path) static ExpressiondayOfYearExp(Expression exp) static ExpressionfunctionCall(String function, Object... args) static Expressionstatic ExpressionhourExp(Expression exp) static Expressionstatic ExpressionlengthExp(Expression exp) static ExpressionCall LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static ExpressionlocateExp(String substring, Expression exp) Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static ExpressionlocateExp(Expression substring, Expression exp) Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static Expressionstatic ExpressionlowerExp(Expression exp) static ExpressionmaxExp(Expression exp) static ExpressionminExp(Expression exp) static Expressionstatic ExpressionminuteExp(Expression exp) static Expressionstatic ExpressionmodExp(Expression exp, Number number) static ExpressionmodExp(Expression exp, Expression number) static Expressionstatic ExpressionmonthExp(Expression exp) static Expressionstatic Expressionstatic ExpressionsecondExp(Expression exp) static Expressionstatic ExpressionsqrtExp(Expression exp) static ExpressionsubstringExp(String path, int offset, int length) Call SUBSTRING(string, offset, length) functionstatic ExpressionsubstringExp(Expression exp, int offset, int length) Call SUBSTRING(string, offset, length) functionstatic ExpressionsubstringExp(Expression exp, Expression offset, Expression length) Call SUBSTRING(string, offset, length) functionstatic ExpressionsumExp(Expression exp) static Expressionstatic ExpressiontrimExp(Expression exp) static Expressionstatic ExpressionupperExp(Expression exp) static Expressionstatic ExpressionweekExp(Expression exp) static Expressionstatic ExpressionyearExp(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
-