Class JDBCExpressionFactory
java.lang.Object
org.apache.openjpa.jdbc.kernel.exps.JDBCExpressionFactory
- All Implemented Interfaces:
Serializable
,ExpressionFactory
Expression factory implementation that can be used to execute queries
via SQL.
- Author:
- Abe White
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn a value representing the absolute value of the given one.Return a value representing the two values added together.Return an expression representing the given condition.and
(Expression exp1, Expression exp2) Return the two expressions AND'd together.Return an expression representing the given condition.Return the given value as an expression.Return the average of the given value for all matches.bindKeyVariable
(Value var, Value val) Bind the given variable to the key set of the given map value.bindValueVariable
(Value var, Value val) Bind the given variable to the value set of the given map value.bindVariable
(Value var, Value val) Bind the given variable to the given collection value.Cast the value to the given class.coalesceExpression
(Value[] vals) Return a coalesce expressionReturn a value representing the concatenation of the given target with the given args.Return an expression representing the given condition.containsKey
(Value map, Value arg) Return an expression representing the given condition.containsValue
(Value map, Value arg) Return an expression representing the given condition.Return the count of the given value for all matches.Return distinct values of the given value.Return a value representing the first value divided by the first one.Return a blank expression; this is used when the filter is empty.Return whether the first string ends with the second.Return an expression representing the given condition.generalCaseExpression
(Expression[] exp, Value val) Return a general case expressiongetCurrentDate
(Class<T> dateType) Return a value representing the current date.getCurrentTime
(Class<T> dateType) Return a value representing the current time.getCurrentTimestamp
(Class<T> dateType) Return a value representing the current timestamp.Path navigation thru map keygetMapValue
(Value map, Value arg) Return an expression representing the given condition.getNull()
Return a value representing null.getObjectId
(Value val) Return the object id of the given value.Use to create SQL select.getThis()
Return a value representingthis
.greaterThan
(Value v1, Value v2) Return an expression representing the given condition.greaterThanEqual
(Value v1, Value v2) Return an expression representing the given condition.Return an index/position of the given value within a collection/map.Return a value representing the indexOf (LOCATE in JPQL) function on the given target with the given args.Return an expression representing the given condition.isInstance
(Value val, Class c) Return whether the first value is an instance of the given class.isNotEmpty
(Value val) Return an expression representing the given condition.boolean
isVerticalType
(Value val) Return true if the Value is a Type expression and the Type uses joined table strategy.Return an expression representing the given condition.lessThanEqual
(Value v1, Value v2) Return an expression representing the given condition.Return the map entry of the given value.Return the map key of the given valueReturn whether the string matches the matching pattern.Return the max of the given value for all matches.Return the max of the given value for all matches.Return a value representing the first value mod'd by the second one.Return a value representing the two values multiplied together.newAggregate
(AggregateListener listener, Value arg) Return the value of the given function.newArgumentList
(Value... vs) Return a function argument list consisting of the given values, any of which may itself be an argument list.newArgumentList
(Value v1, Value v2) Return a function argument list consisting of the given values, either of which may itself be an argument list.newBoundVariable
(String name, Class type) This method will be called only once per variable bound in acontains
clause, and the returned value will be reused for any further instances of the variable in subexpression of the filter string.newCollectionValuedParameter
(Object key, Class type) Return a value representing a collection-valued parameter.newExtension
(FilterListener listener, Value target, Value arg) Return the value of the given extension.newFunction
(String functionName, Class<?> resultType, Value... args) Return a value representing the given datastore function with the given arguments.newLiteral
(Object val, int ptype) newParameter
(Object name, Class type) Return a value representing a parameter for the given value.newPath()
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the candidate class.
Example:parent.address.city
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the given value.
Example:var.address.city
newSubquery
(ClassMetaData candidate, boolean subs, String alias) Return a subquery.newTypeLiteral
(Object val, int ptype) newUnboundVariable
(String name, Class type) Return an unbound variable.not
(Expression exp) Return the inverse of this expression.Return an expression representing the given condition.Return whether the string does not match the given pattern.nullIfExpression
(Value val1, Value val2) Return a nullif expressionor
(Expression exp1, Expression exp2) Return the two expressions OR'd together.void
setBooleanLiteralAsNumeric
(boolean isBooleanLiteralAsNumeric) simpleCaseExpression
(Value caseOperand, Expression[] exp, Value val1) Return a simple case expressionReturn an expression representing the given condition.Return the square root of the given value.startsWith
(Value v1, Value v2) Return whether the first string starts with the second.stringLength
(Value str) Returns the number of characters in the String value.Return a value representing the substring function on the given target with the given args.Return a value representing the second value subtracted from the first.Return the max of the given value for all matches.toLowerCase
(Value val) Return the upper case of the given value.toUpperCase
(Value val) Return the upper case of the given value.Trims the specified specified trimChar from the specified value.Return the type/class of the given value.whenCondition
(Expression exp, Value val) Return a when condidional clausewhenScalar
(Value val1, Value val2) Return a when scalar_expression clause
-
Constructor Details
-
JDBCExpressionFactory
Constructor. Supply the type we're querying against.
-
-
Method Details
-
setBooleanLiteralAsNumeric
public void setBooleanLiteralAsNumeric(boolean isBooleanLiteralAsNumeric) -
getSelectConstructor
Use to create SQL select. -
emptyExpression
Description copied from interface:ExpressionFactory
Return a blank expression; this is used when the filter is empty.- Specified by:
emptyExpression
in interfaceExpressionFactory
-
asExpression
Description copied from interface:ExpressionFactory
Return the given value as an expression.- Specified by:
asExpression
in interfaceExpressionFactory
-
equal
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
equal
in interfaceExpressionFactory
-
notEqual
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
notEqual
in interfaceExpressionFactory
-
lessThan
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
lessThan
in interfaceExpressionFactory
-
greaterThan
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
greaterThan
in interfaceExpressionFactory
-
lessThanEqual
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
lessThanEqual
in interfaceExpressionFactory
-
greaterThanEqual
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
greaterThanEqual
in interfaceExpressionFactory
-
isEmpty
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
isEmpty
in interfaceExpressionFactory
-
isNotEmpty
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
isNotEmpty
in interfaceExpressionFactory
-
contains
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
contains
in interfaceExpressionFactory
-
containsKey
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
containsKey
in interfaceExpressionFactory
-
containsValue
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
containsValue
in interfaceExpressionFactory
-
isInstance
Description copied from interface:ExpressionFactory
Return whether the first value is an instance of the given class.- Specified by:
isInstance
in interfaceExpressionFactory
-
and
Description copied from interface:ExpressionFactory
Return the two expressions AND'd together.- Specified by:
and
in interfaceExpressionFactory
-
or
Description copied from interface:ExpressionFactory
Return the two expressions OR'd together.- Specified by:
or
in interfaceExpressionFactory
-
not
Description copied from interface:ExpressionFactory
Return the inverse of this expression.- Specified by:
not
in interfaceExpressionFactory
-
bindVariable
Description copied from interface:ExpressionFactory
Bind the given variable to the given collection value.- Specified by:
bindVariable
in interfaceExpressionFactory
-
bindKeyVariable
Description copied from interface:ExpressionFactory
Bind the given variable to the key set of the given map value.- Specified by:
bindKeyVariable
in interfaceExpressionFactory
-
bindValueVariable
Description copied from interface:ExpressionFactory
Bind the given variable to the value set of the given map value.- Specified by:
bindValueVariable
in interfaceExpressionFactory
-
startsWith
Description copied from interface:ExpressionFactory
Return whether the first string starts with the second.- Specified by:
startsWith
in interfaceExpressionFactory
-
endsWith
Description copied from interface:ExpressionFactory
Return whether the first string ends with the second.- Specified by:
endsWith
in interfaceExpressionFactory
-
notMatches
Description copied from interface:ExpressionFactory
Return whether the string does not match the given pattern.- Specified by:
notMatches
in interfaceExpressionFactory
- Parameters:
v1
- the value to comparev2
- the pattern against which to comparesingle
- the token that signifies a single-character matchmulti
- the token that signifies a multi-character matchesc
- the escape token that escapes the matching tokens
-
matches
Description copied from interface:ExpressionFactory
Return whether the string matches the matching pattern.- Specified by:
matches
in interfaceExpressionFactory
- Parameters:
v1
- the value to comparev2
- the pattern against which to comparesingle
- the token that signifies a single-character matchmulti
- the token that signifies a multi-character matchesc
- the escape token that escapes the matching tokens
-
newSubquery
Description copied from interface:ExpressionFactory
Return a subquery. Paths for the candidates of the subquery are created withExpressionFactory.newPath(Value)
, passing in the subquery as the value.- Specified by:
newSubquery
in interfaceExpressionFactory
- Parameters:
candidate
- the candidate class of the subquerysubs
- whether the query includes subclassesalias
- the alias given to the query candidate class
-
newPath
Description copied from interface:ExpressionFactory
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the candidate class.
Example:parent.address.city
- Specified by:
newPath
in interfaceExpressionFactory
-
newPath
Description copied from interface:ExpressionFactory
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the given value.
Example:var.address.city
- Specified by:
newPath
in interfaceExpressionFactory
-
newLiteral
Description copied from interface:ExpressionFactory
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.- Specified by:
newLiteral
in interfaceExpressionFactory
-
newTypeLiteral
Description copied from interface:ExpressionFactory
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.- Specified by:
newTypeLiteral
in interfaceExpressionFactory
-
getThis
Description copied from interface:ExpressionFactory
Return a value representingthis
.- Specified by:
getThis
in interfaceExpressionFactory
-
getNull
Description copied from interface:ExpressionFactory
Return a value representing null.- Specified by:
getNull
in interfaceExpressionFactory
-
getCurrentDate
Description copied from interface:ExpressionFactory
Return a value representing the current date.- Specified by:
getCurrentDate
in interfaceExpressionFactory
-
getCurrentTime
Description copied from interface:ExpressionFactory
Return a value representing the current time.- Specified by:
getCurrentTime
in interfaceExpressionFactory
-
getCurrentTimestamp
Description copied from interface:ExpressionFactory
Return a value representing the current timestamp.- Specified by:
getCurrentTimestamp
in interfaceExpressionFactory
-
newParameter
Description copied from interface:ExpressionFactory
Return a value representing a parameter for the given value. The type may beObject
if the parameter is not declared.- Specified by:
newParameter
in interfaceExpressionFactory
-
newCollectionValuedParameter
Description copied from interface:ExpressionFactory
Return a value representing a collection-valued parameter. The type may beObject
if the parameter is not declared.- Specified by:
newCollectionValuedParameter
in interfaceExpressionFactory
-
newExtension
Description copied from interface:ExpressionFactory
Return the value of the given extension.- Specified by:
newExtension
in interfaceExpressionFactory
-
newAggregate
Description copied from interface:ExpressionFactory
Return the value of the given function.- Specified by:
newAggregate
in interfaceExpressionFactory
-
newArgumentList
Description copied from interface:ExpressionFactory
Return a function argument list consisting of the given values, either of which may itself be an argument list.- Specified by:
newArgumentList
in interfaceExpressionFactory
-
newArgumentList
Description copied from interface:ExpressionFactory
Return a function argument list consisting of the given values, any of which may itself be an argument list.- Specified by:
newArgumentList
in interfaceExpressionFactory
-
newUnboundVariable
Description copied from interface:ExpressionFactory
Return an unbound variable. This method will only be called once for a given named unbound variable. The type may beObject
if the variable is not declared.- Specified by:
newUnboundVariable
in interfaceExpressionFactory
-
newBoundVariable
Description copied from interface:ExpressionFactory
This method will be called only once per variable bound in acontains
clause, and the returned value will be reused for any further instances of the variable in subexpression of the filter string. The type may beObject
if the variable is not declared.- Specified by:
newBoundVariable
in interfaceExpressionFactory
-
cast
Description copied from interface:ExpressionFactory
Cast the value to the given class.- Specified by:
cast
in interfaceExpressionFactory
-
add
Description copied from interface:ExpressionFactory
Return a value representing the two values added together.- Specified by:
add
in interfaceExpressionFactory
-
subtract
Description copied from interface:ExpressionFactory
Return a value representing the second value subtracted from the first.- Specified by:
subtract
in interfaceExpressionFactory
-
multiply
Description copied from interface:ExpressionFactory
Return a value representing the two values multiplied together.- Specified by:
multiply
in interfaceExpressionFactory
-
divide
Description copied from interface:ExpressionFactory
Return a value representing the first value divided by the first one.- Specified by:
divide
in interfaceExpressionFactory
-
mod
Description copied from interface:ExpressionFactory
Return a value representing the first value mod'd by the second one.- Specified by:
mod
in interfaceExpressionFactory
-
abs
Description copied from interface:ExpressionFactory
Return a value representing the absolute value of the given one.- Specified by:
abs
in interfaceExpressionFactory
-
indexOf
Description copied from interface:ExpressionFactory
Return a value representing the indexOf (LOCATE in JPQL) function on the given target with the given args. The optional second argument is one-based.- Specified by:
indexOf
in interfaceExpressionFactory
-
concat
Description copied from interface:ExpressionFactory
Return a value representing the concatenation of the given target with the given args.- Specified by:
concat
in interfaceExpressionFactory
-
stringLength
Description copied from interface:ExpressionFactory
Returns the number of characters in the String value.- Specified by:
stringLength
in interfaceExpressionFactory
-
trim
Description copied from interface:ExpressionFactory
Trims the specified specified trimChar from the specified value.- Specified by:
trim
in interfaceExpressionFactory
- Parameters:
str
- the value from which to trimtrimChar
- the characters to trim offwhere
- which side of the String to trim: null indicates both sides, true indicates leading, and false indicates trailing
-
sqrt
Description copied from interface:ExpressionFactory
Return the square root of the given value.- Specified by:
sqrt
in interfaceExpressionFactory
-
substring
Description copied from interface:ExpressionFactory
Return a value representing the substring function on the given target with the given args. Unlike as withString.substring(int)
, the start index is one-based, and the second argument is the length.- Specified by:
substring
in interfaceExpressionFactory
-
toUpperCase
Description copied from interface:ExpressionFactory
Return the upper case of the given value.- Specified by:
toUpperCase
in interfaceExpressionFactory
-
toLowerCase
Description copied from interface:ExpressionFactory
Return the upper case of the given value.- Specified by:
toLowerCase
in interfaceExpressionFactory
-
avg
Description copied from interface:ExpressionFactory
Return the average of the given value for all matches.- Specified by:
avg
in interfaceExpressionFactory
-
count
Description copied from interface:ExpressionFactory
Return the count of the given value for all matches.- Specified by:
count
in interfaceExpressionFactory
-
distinct
Description copied from interface:ExpressionFactory
Return distinct values of the given value. This is typically used within aggregates, for example: max(distinct(path))- Specified by:
distinct
in interfaceExpressionFactory
-
max
Description copied from interface:ExpressionFactory
Return the max of the given value for all matches.- Specified by:
max
in interfaceExpressionFactory
-
min
Description copied from interface:ExpressionFactory
Return the max of the given value for all matches.- Specified by:
min
in interfaceExpressionFactory
-
sum
Description copied from interface:ExpressionFactory
Return the max of the given value for all matches.- Specified by:
sum
in interfaceExpressionFactory
-
any
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
any
in interfaceExpressionFactory
-
all
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
all
in interfaceExpressionFactory
-
size
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
size
in interfaceExpressionFactory
-
index
Description copied from interface:ExpressionFactory
Return an index/position of the given value within a collection/map.- Specified by:
index
in interfaceExpressionFactory
-
type
Description copied from interface:ExpressionFactory
Return the type/class of the given value.- Specified by:
type
in interfaceExpressionFactory
-
mapEntry
Description copied from interface:ExpressionFactory
Return the map entry of the given value.- Specified by:
mapEntry
in interfaceExpressionFactory
-
mapKey
Description copied from interface:ExpressionFactory
Return the map key of the given value- Specified by:
mapKey
in interfaceExpressionFactory
-
getKey
Description copied from interface:ExpressionFactory
Path navigation thru map key- Specified by:
getKey
in interfaceExpressionFactory
-
getObjectId
Description copied from interface:ExpressionFactory
Return the object id of the given value.- Specified by:
getObjectId
in interfaceExpressionFactory
-
getMapValue
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
getMapValue
in interfaceExpressionFactory
-
simpleCaseExpression
Description copied from interface:ExpressionFactory
Return a simple case expression- Specified by:
simpleCaseExpression
in interfaceExpressionFactory
-
generalCaseExpression
Description copied from interface:ExpressionFactory
Return a general case expression- Specified by:
generalCaseExpression
in interfaceExpressionFactory
-
whenCondition
Description copied from interface:ExpressionFactory
Return a when condidional clause- Specified by:
whenCondition
in interfaceExpressionFactory
-
whenScalar
Description copied from interface:ExpressionFactory
Return a when scalar_expression clause- Specified by:
whenScalar
in interfaceExpressionFactory
-
coalesceExpression
Description copied from interface:ExpressionFactory
Return a coalesce expression- Specified by:
coalesceExpression
in interfaceExpressionFactory
-
nullIfExpression
Description copied from interface:ExpressionFactory
Return a nullif expression- Specified by:
nullIfExpression
in interfaceExpressionFactory
-
newFunction
Description copied from interface:ExpressionFactory
Return a value representing the given datastore function with the given arguments.- Specified by:
newFunction
in interfaceExpressionFactory
-
isVerticalType
Description copied from interface:ExpressionFactory
Return true if the Value is a Type expression and the Type uses joined table strategy.- Specified by:
isVerticalType
in interfaceExpressionFactory
-