public abstract class DataExpression extends BaseExpression
shouldUseUpperCaseForIgnoreCase
Constructor and Description |
---|
DataExpression()
DataExpression constructor comment.
|
Modifier and Type | Method and Description |
---|---|
void |
addDerivedField(Expression addThis) |
void |
addDerivedTable(Expression addThis) |
DatabaseTable |
aliasForTable(DatabaseTable table)
INTERNAL:
Find the alias for a given table
|
Expression |
asOf(AsOfClause clause)
Sets all tables represented by this expression to be queried as of a past
time.
|
void |
clearAliases()
INTERNAL:
|
java.util.List<Expression> |
copyCollection(java.util.List<Expression> in,
java.util.Map alreadyDone) |
boolean |
equals(java.lang.Object object)
INTERNAL:
Return if the expression is equal to the other.
|
Expression |
existingDerivedField(DatabaseField field)
INTERNAL:
|
Expression |
existingDerivedTable(DatabaseTable table)
INTERNAL:
|
Expression |
getAlias(Expression subSelect)
ADVANCED: Return an expression representing a sub-select in the from clause.
|
DatabaseField |
getAliasedField()
INTERNAL:
Return the field appropriately aliased
|
AsOfClause |
getAsOfClause()
Answers the past time the expression is explicitly as of.
|
ClassDescriptor |
getContainingDescriptor()
INTERNAL:
Return the descriptor which contains this query key.
|
ClassDescriptor |
getDescriptor() |
DatabaseField |
getField()
INTERNAL:
|
Expression |
getField(DatabaseField field)
ADVANCED: Return an expression representing a field in a data-level query.
|
Expression |
getField(java.lang.String fieldName)
ADVANCED:
Return an expression representing a field in a data-level query.
|
DatabaseMapping |
getMapping() |
QueryKey |
getQueryKeyOrNull() |
Expression |
getTable(DatabaseTable table)
ADVANCED: Return an expression representing a table in a data-level query.
|
Expression |
getTable(java.lang.String tableName)
ADVANCED: Return an expression representing a table in a data-level query.
|
TableAliasLookup |
getTableAliases()
INTERNAL:
Return the aliases used.
|
boolean |
hasAsOfClause()
ADVANCED:
Answers true if
this is to be queried as of a past time. |
boolean |
hasBeenAliased()
INTERNAL:
Answers if the database tables associated with this expression have been
aliased.
|
boolean |
hasBeenNormalized()
INTERNAL:
Did the normalizer already add additional joins to the where clause due to
this query key representing a foreign reference mapping?
This insures that join criteria (for any query key expression) is not
added twice.
|
boolean |
isAttribute()
INTERNAL:
|
boolean |
isDataExpression()
INTERNAL:
|
void |
iterateOn(ExpressionIterator iterator)
INTERNAL:
For iterating using an inner class
|
Expression |
newDerivedField(DatabaseField field)
INTERNAL:
|
Expression |
newDerivedTable(DatabaseTable table)
INTERNAL:
|
Expression |
normalize(ExpressionNormalizer normalizer)
INTERNAL:
Normalize the expression into a printable structure.
|
void |
printSQL(ExpressionSQLPrinter printer)
INTERNAL:
Print SQL onto the stream, using the ExpressionPrinter for context
|
void |
setHasBeenNormalized(boolean value) |
void |
setTableAliases(TableAliasLookup tableAliases)
INTERNAL:
For CR#2456, Table identity involves having two tables sharing the same
aliasing table.
|
java.lang.String |
tableAliasesDescription() |
void |
writeSubexpressionsTo(java.io.BufferedWriter writer,
int indent)
Print the base for debuggin purposes.
|
getBaseExpression, getBuilder, resetPlaceHolderBuilder, setBaseExpression, shallowClone
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, computeHashCode, concat, containsAllKeyWords, containsAnyKeyWords, containsSubstring, containsSubstring, containsSubstringIgnoringCase, containsSubstringIgnoringCase, convertToUseOuterJoin, copiedVersionFrom, count, create, create, createWithBaseLast, currentDate, currentDateDate, currentTime, currentTimeStamp, dateDifference, dateDifference, dateName, datePart, dateToString, decode, descending, descriptionOfNodeType, 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, getAllowingNull, getAsOfClauseRecursively, getClonedField, getFields, getFieldValue, getFunction, getFunction, getFunction, getFunction, getFunction, getFunctionWithArguments, getFunctionWithArguments, getLeafDescriptor, getLeafMapping, getName, getNumberVal, getOperator, getOperator, getOwnedTables, getParameter, getParameter, getParameter, getProperty, getSelectionFields, getSelectionFields, getSession, getStringVal, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, hashCode, hexToRaw, ifNull, in, in, in, in, in, in, in, in, in, in, in, in, index, indexOf, intersect, intersect, intersectAll, intersectAll, isClassTypeExpression, isCompoundExpression, isConstantExpression, 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, printJava, rebuildOn, 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, twistedForBaseAndContext, type, union, union, unionAll, unionAll, validateNode, value, value, value, value, value, value, value, value, value, value, valueFromObject, valueFromObject, variance, writeDescriptionOn, writeFields
public boolean equals(java.lang.Object object)
equals
in class Expression
public void addDerivedField(Expression addThis)
public void addDerivedTable(Expression addThis)
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 DatabaseTable aliasForTable(DatabaseTable table)
aliasForTable
in class Expression
public void clearAliases()
public java.util.List<Expression> copyCollection(java.util.List<Expression> in, java.util.Map alreadyDone)
public Expression existingDerivedField(DatabaseField field)
public Expression existingDerivedTable(DatabaseTable table)
public DatabaseField getAliasedField()
public AsOfClause getAsOfClause()
Expression
getAsOfClause
in class Expression
null
if no clause set, AsOfClause.NO_CLAUSE
if
clause explicitly set to null
.Expression.asOf(org.eclipse.persistence.history.AsOfClause)
,
Expression.hasAsOfClause()
public ClassDescriptor getDescriptor()
public DatabaseField getField()
public Expression getField(java.lang.String fieldName)
Expression
Example:
builder.getField("ADDR_ID").greaterThan(100); builder.getTable("PROJ_EMP").getField("TYPE").equal("S");
getField
in class Expression
public Expression getField(DatabaseField field)
Expression
Example:
builder.getField(aField).greaterThan(100);
getField
in class Expression
public ClassDescriptor getContainingDescriptor()
public DatabaseMapping getMapping()
public QueryKey getQueryKeyOrNull()
public Expression getTable(java.lang.String tableName)
Expression
Example:
builder.getTable("PROJ_EMP").getField("TYPE").equal("S");
getTable
in class Expression
public Expression getTable(DatabaseTable table)
Expression
Example:
builder.getTable(linkTable).getField("TYPE").equal("S");
getTable
in class Expression
public TableAliasLookup getTableAliases()
getTableAliases
in class Expression
public boolean hasBeenNormalized()
New meaning: DataExpressions are often iterated on multiple times during normalize, but Function/Relation expressions only once. Adding a has been normalized flag improves performance and is required in some applications, such as have temporal query criteria been added.
public boolean hasAsOfClause()
Expression
this
is to be queried as of a past time.hasAsOfClause
in class Expression
asOf(null); hasAsOfClause()
.Expression.getAsOfClause()
public boolean hasBeenAliased()
Expression
hasBeenAliased
in class Expression
public boolean isAttribute()
public boolean isDataExpression()
Expression
isDataExpression
in class Expression
public void iterateOn(ExpressionIterator iterator)
iterateOn
in class Expression
public Expression newDerivedField(DatabaseField field)
public Expression newDerivedTable(DatabaseTable table)
public Expression getAlias(Expression subSelect)
Example:
builder.getAlias(builder.subQuery(reportQuery)).get("type").equal("S");
getAlias
in class Expression
public Expression normalize(ExpressionNormalizer normalizer)
normalize
in class Expression
public void printSQL(ExpressionSQLPrinter printer)
printSQL
in class Expression
public void setHasBeenNormalized(boolean value)
public void setTableAliases(TableAliasLookup tableAliases)
public java.lang.String tableAliasesDescription()
public void writeSubexpressionsTo(java.io.BufferedWriter writer, int indent) throws java.io.IOException
writeSubexpressionsTo
in class Expression
java.io.IOException
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference