public abstract class CompoundExpression extends Expression
shouldUseUpperCaseForIgnoreCase
Constructor and Description |
---|
CompoundExpression() |
Modifier and Type | Method and Description |
---|---|
DatabaseTable |
aliasForTable(DatabaseTable table)
INTERNAL:
Find the alias for a given table from the first or second child in the additionalOuterJoinCriteria
|
Expression |
asOf(AsOfClause clause)
Sets all tables represented by this expression to be queried as of a past
time.
|
int |
computeHashCode()
INTERNAL:
Compute a consistent hash-code for the expression.
|
Expression |
create(Expression base,
java.util.List arguments,
ExpressionOperator operator)
INTERNAL:
|
Expression |
create(Expression base,
java.lang.Object singleArgument,
ExpressionOperator operator)
INTERNAL:
|
java.lang.String |
descriptionOfNodeType()
INTERNAL:
Used for debug printing.
|
boolean |
equals(java.lang.Object object)
INTERNAL:
Return if the expression is equal to the other.
|
ExpressionBuilder |
getBuilder()
Return the expression builder which is the ultimate base of this expression, or
null if there isn't one (shouldn't happen if we start from a root)
|
Expression |
getFirstChild() |
ExpressionOperator |
getOperator()
INTERNAL:
Most expression have operators, so this is just a convenience method.
|
ExpressionOperator |
getPlatformOperator(DatabasePlatform platform) |
Expression |
getSecondChild() |
void |
initializePlatformOperator(DatabasePlatform platform)
INTERNAL:
|
boolean |
isCompoundExpression()
INTERNAL:
|
void |
iterateOn(ExpressionIterator iterator)
INTERNAL:
For iterating using an inner class
|
Expression |
normalize(ExpressionNormalizer normalizer)
INTERNAL:
Normalize into a structure that is printable.
|
void |
printJava(ExpressionJavaPrinter printer)
INTERNAL:
Print java for project class generation
|
void |
printSQL(ExpressionSQLPrinter printer)
INTERNAL:
Print SQL
|
Expression |
rebuildOn(Expression newBase)
INTERNAL:
This expression is built on a different base than the one we want.
|
void |
resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)
INTERNAL:
Search the tree for any expressions (like SubSelectExpressions) that have been
built using a builder that is not attached to the query.
|
void |
setOperator(ExpressionOperator newOperator) |
Expression |
shallowClone()
INTERNAL:
Clear the builder when cloning.
|
Expression |
twistedForBaseAndContext(Expression newBase,
Expression context,
Expression oldBase)
INTRENAL:
Used to change an expression off of one base to an expression off of a different base.
|
void |
validateNode()
Do any required validation for this node.
|
void |
writeDescriptionOn(java.io.BufferedWriter writer)
INTERNAL:
Used to print a debug form of the expression tree.
|
void |
writeSubexpressionsTo(java.io.BufferedWriter writer,
int indent)
INTERNAL:
Used for toString for debugging only.
|
addDate, addDate, addMonths, addMonths, alias, all, all, all, all, all, all, all, all, all, all, all, all, all, allOf, and, any, any, any, any, any, any, any, any, any, any, any, any, any, anyOf, anyOf, anyOfAllowingNone, anyOfAllowingNone, as, as, ascending, asciiValue, assignTableAliasesStartingAt, average, between, between, between, between, between, between, between, between, between, caseConditionStatement, caseConditionStatement, caseStatement, caseStatement, cast, clone, cloneUsing, coalesce, coalesce, concat, containsAllKeyWords, containsAnyKeyWords, containsSubstring, containsSubstring, containsSubstringIgnoringCase, containsSubstringIgnoringCase, convertToUseOuterJoin, copiedVersionFrom, count, createWithBaseLast, currentDate, currentDateDate, currentTime, currentTimeStamp, dateDifference, dateDifference, dateName, datePart, dateToString, decode, descending, difference, distinct, doesConform, doesConform, equal, equal, equal, equal, equal, equal, equal, equal, equal, equal, equalOuterJoin, equalOuterJoin, equalsIgnoreCase, equalsIgnoreCase, except, except, exceptAll, exceptAll, exists, existsNode, extract, extractFields, extractPrimaryKeyValues, extractValue, extractValues, extractXml, from, fromConstant, fromLiteral, get, get, getAlias, getAllowingNull, getAsOfClause, getAsOfClauseRecursively, getClonedField, getField, getField, getFields, getFieldValue, getFunction, getFunction, getFunction, getFunction, getFunction, getFunctionWithArguments, getFunctionWithArguments, getLeafDescriptor, getLeafMapping, getName, getNumberVal, getOperator, getOwnedTables, getParameter, getParameter, getParameter, getProperty, getSelectionFields, getSelectionFields, getSession, getStringVal, getTable, getTable, getTableAliases, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, hasAsOfClause, hasBeenAliased, hashCode, hexToRaw, ifNull, in, in, in, in, in, in, in, in, in, in, in, in, index, indexOf, intersect, intersect, intersectAll, intersectAll, isClassTypeExpression, isConstantExpression, isDataExpression, isEmpty, isExpressionBuilder, isFieldExpression, isFragment, isFunctionExpression, isLiteralExpression, isLogicalExpression, isMapEntryExpression, isNull, isObjectExpression, isParameterExpression, isQueryKeyExpression, isRelationExpression, isSubSelectExpression, isTableExpression, isTreatExpression, isValueExpression, join, lastDay, leftJoin, leftPad, leftPad, leftTrim, leftTrim, length, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, like, like, like, like, likeIgnoreCase, likeIgnoreCase, literal, locate, locate, locate, mapEntry, mapKey, maximum, minimum, monthsBetween, newTime, nextDay, noneOf, not, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notEmpty, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notExists, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notLike, notLike, notLike, notLike, notNull, nullIf, nullsFirst, nullsLast, operator, or, performOperator, postfixSQL, prefixSQL, ref, regexp, regexp, replace, replicate, replicate, reverse, right, right, rightPad, rightPad, rightTrim, rightTrim, roundDate, selectIfOrderedBy, setLocalBase, setSelectIfOrderedBy, size, size, some, some, some, some, some, some, some, some, some, some, some, some, some, sql, standardDeviation, subQuery, substring, substring, substring, substring, sum, toChar, toChar, toCharacter, toDate, toLowerCase, toNumber, toString, toString, toUpperCase, toUppercaseCasedWords, translate, treat, trim, trim, truncateDate, twist, type, union, union, unionAll, unionAll, value, value, value, value, value, value, value, value, value, value, valueFromObject, valueFromObject, variance, writeFields
public boolean equals(java.lang.Object object)
equals
in class Expression
public int computeHashCode()
computeHashCode
in class Expression
public DatabaseTable aliasForTable(DatabaseTable table)
aliasForTable
in class Expression
public Expression asOf(AsOfClause clause)
Expression
Example:
EclipseLink: employee.asOf(new AsOfClause(pastTime)) Java: None SQL (Flashback): SELECT ... FROM EMPLOYEE AS OF TIMESTAMP (pastTime) t0 ... SQL (Generic): .. WHERE (t1.START <= pastTime) AND ((t1.END IS NULL) OR t1.END > pastTime)
Set an as of clause at the expression level to still query for current objects while expressing selection criteria like:
Simultaneously querying on two versions of the same object (one past one present) lets you express these advanced selection criteria.
Example: Querying on past attributes using parallel expressions.
// Finds all employees who lived in Ottawa as of a past time. ExpressionBuilder employee = new ExpressionBuilder(); ExpressionBuilder pastEmployee = new ExpressionBuilder(Employee.class); pastEmployee.asOf(pastTime); Expression pastAddress = pastEmployee.get("address"); // by default address will also be as of past time. Expression selectionCriteria = pastAddress.get("city").equal("Ottawa").and( employee.equal(pastEmployee));
The advantage of the parallel expression is that you can still read current objects, the as of clause will affect only the where clause / selection criteria.
You may be tempted to rewrite the above as employee.get("address").asOf(pastTime). That is allowed but see below for the finer points involved in this.
Example: Querying on object changes using parallel expressions.
// Finds all employees who recently received a raise. Note that current // objects are returned, so can be cached normally. ExpressionBuilder employee = new ExpressionBuilder(); Expression pastEmployee = new ExpressionBuilder(Employee.class); pastEmployee.asOf(yesterday); Expression parallelJoin = employee.equal(pastEmployee); Expression selectionCriteria = parallelJoin.and( employee.get("salary").greaterThan(pastEmployee.get("salary")));
Example: Querying on object changes using custom query keys
// First define the custom query key and add it to your descriptor. ExpressionBuilder builder = new ExpressionBuilder(Employee.class); Expression joinCriteria = builder.getField("EMPLOYEE.EMP_ID").equal(builder.getParameter("EMPLOYEE.EMP_ID")); OneToOneQueryKey selfReferential = new OneToOneQueryKey(); selfReferential.setName("this"); selfReferential.setJoinCriteria(joinCriteria); selfReferential.setReferenceClass(Employee.class); getSession().getDescriptor(Employee.class).addQueryKey(selfReferential); // Now build query as before. Expression employee = new ExpessionBuilder(); Expression pastEmployee = employee.get("this").asOf(yesterday); Expression selectionCriteria = employee.get("salary").greaterThan(pastEmployee.get("salary"));
Note in general that any parallel expression can be rewritten using a custom query key. EclipseLink will even automatically interpret x.get("this") for you so you do not need to define the above query key first.
Full Reference:
If an object is mapped to multiple tables, then each table will be as of the same time. Two objects mapped to the same table can not have different as of times. Conversely only expressions which have associated tables can have an as of clause.
If an as of clause is not explicitly set an expression will use the clause of its base expression, and so on recursively until one is found or an ExpressionBuilder is reached. Some usage scenarios follow:
Watch out for x.asOf(oneTime).get("y").asOf(anotherTime).
asOf
in class Expression
clause
- A read only data object used to represent a past time.this
AsOfClause
,
Expression.hasAsOfClause()
,
Session.acquireHistoricalSession(org.eclipse.persistence.history.AsOfClause)
,
ObjectLevelReadQuery.setAsOfClause(org.eclipse.persistence.history.AsOfClause)
public Expression create(Expression base, java.lang.Object singleArgument, ExpressionOperator operator)
create
in class Expression
public Expression create(Expression base, java.util.List arguments, ExpressionOperator operator)
create
in class Expression
public java.lang.String descriptionOfNodeType()
descriptionOfNodeType
in class Expression
public ExpressionBuilder getBuilder()
getBuilder
in class Expression
public Expression getFirstChild()
public ExpressionOperator getOperator()
Expression
getOperator
in class Expression
public ExpressionOperator getPlatformOperator(DatabasePlatform platform)
public Expression getSecondChild()
public void initializePlatformOperator(DatabasePlatform platform)
public boolean isCompoundExpression()
Expression
isCompoundExpression
in class Expression
public void iterateOn(ExpressionIterator iterator)
iterateOn
in class Expression
public Expression normalize(ExpressionNormalizer normalizer)
normalize
in class Expression
public void validateNode()
validateNode
in class Expression
public void printSQL(ExpressionSQLPrinter printer)
printSQL
in class Expression
public void printJava(ExpressionJavaPrinter printer)
printJava
in class Expression
public Expression rebuildOn(Expression newBase)
rebuildOn
in class Expression
Expression.cloneUsing(Expression newBase)
public void resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)
resetPlaceHolderBuilder
in class Expression
public void setOperator(ExpressionOperator newOperator)
public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)
twistedForBaseAndContext
in class Expression
public void writeDescriptionOn(java.io.BufferedWriter writer) throws java.io.IOException
writeDescriptionOn
in class Expression
java.io.IOException
public void writeSubexpressionsTo(java.io.BufferedWriter writer, int indent) throws java.io.IOException
writeSubexpressionsTo
in class Expression
java.io.IOException
public Expression shallowClone()
shallowClone
in class Expression
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference