public class ExpressionBuilder extends ObjectExpression
Purpose: Allow for instances of expression to be created. Expressions are Java object-level representations of SQL "where" clauses. The expressions attempt to mirror Java code as closely as possible.
Example:
ExpressionBuilder employee = new ExpressionBuilder(); employee.get("firstName").equal("Bob").and(employee.get("lastName").equal("Smith")) >> equivalent Java code: (employee.getFirstName().equals("Bob")) && (employee.getLastName().equals("Smith")) >> equivalent SQL: (F_NAME = 'Bob') AND (L_NAME = 'Smith')
Expression
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected DatabaseTable |
aliasedViewTable |
protected Class |
queryClass |
protected AbstractSession |
session |
protected SQLSelectStatement |
statement |
protected DatabaseTable |
viewTable |
protected boolean |
wasAdditionJoinCriteriaUsed |
protected boolean |
wasQueryClassSetInternally |
derivedExpressions, descriptor, shouldUseOuterJoin, shouldUseOuterJoinForMultitableInheritance
baseExpression, derivedFields, derivedTables, hasBeenNormalized, tableAliases
currentAlias, lastTable, selectIfOrderedBy
Constructor and Description |
---|
ExpressionBuilder()
PUBLIC:
Create a new ExpressionBuilder.
|
ExpressionBuilder(Class queryClass)
ADVANCED:
Create a new ExpressionBuilder representing instances of the argument class.
|
Modifier and Type | Method and Description |
---|---|
DatabaseTable |
aliasForTable(DatabaseTable table)
INTERNAL: Find the alias for a given table.
|
int |
assignTableAliasesStartingAt(int initialValue)
INTERNAL:
Assign aliases to any tables which I own.
|
String |
descriptionOfNodeType()
INTERNAL:
Used for debug printing.
|
boolean |
doesNotRepresentAnObjectInTheQuery()
INTERNAL:
There are cases (which we might want to eliminate?) where the expression builder
doesn't actually correspond to an object to be read.
|
DatabaseTable |
getAliasedViewTable()
INTERNAL:
|
ExpressionBuilder |
getBuilder()
INTERNAL:
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)
|
ClassDescriptor |
getDescriptor()
INTERNAL:
Only usable after the session and class have been set.
|
Class |
getQueryClass()
INTERNAL:
|
AbstractSession |
getSession()
INTERNAL:
|
SQLSelectStatement |
getStatement()
INTERNAL:
Return the statement that expression is for.
|
DatabaseTable |
getViewTable()
INTERNAL:
|
boolean |
hasViewTable()
INTERNAL:
|
boolean |
isExpressionBuilder()
INTERNAL:
|
Expression |
normalize(ExpressionNormalizer normalizer)
INTERNAL:
Normalize the expression into a printable structure.
|
void |
printJava(ExpressionJavaPrinter printer)
INTERNAL:
Print java
|
Expression |
rebuildOn(Expression newBase)
INTERNAL:
This expression is built on a different base than the one we want.
|
protected Expression |
registerIn(Dictionary alreadyDone)
INTERNAL:
Override Expression.registerIn to check if the new base expression
has already been provided for the clone.
|
void |
setQueryClass(Class queryClass)
INTERNAL:
Set the class which this node represents.
|
void |
setSession(AbstractSession session)
INTERNAL:
Set the session in which we expect this expression to be translated.
|
void |
setStatement(SQLSelectStatement statement)
INTERNAL:
Set the statement that expression is for.
|
void |
setViewTable(DatabaseTable theTable)
INTERNAL:
This expression represents something read through a view table.
|
void |
setWasAdditionJoinCriteriaUsed(boolean joinCriteriaUsed)
INTERNAL:
If the additional Join Criteria for the class this builder represents has
been added to the statement then mark this as true.
|
Expression |
twistedForBaseAndContext(Expression newBase,
Expression context)
INTERNAL:
Rebuild myself against the base, with the values of parameters supplied by the context
expression.
|
Object |
valueFromObject(Object object,
AbstractSession session,
AbstractRecord translationRow,
InMemoryQueryIndirectionPolicy valueHolderPolicy,
boolean isObjectUnregistered)
INTERNAL:
The expression builder represent the entire object, just return it.
|
boolean |
wasAdditionJoinCriteriaUsed()
INTERNAL:
If the additional Join Criteria for the class this builder represents has
been added to the statement this method will return true;
|
boolean |
wasQueryClassSetInternally()
INTERNAL:
Returns true if TopLink set the query class as appoased to the customer.
|
void |
writeDescriptionOn(BufferedWriter writer)
INTERNAL:
For debug printing purposes.
|
addDerivedExpression, additionalExpressionCriteria, additionalExpressionCriteriaMap, anyOf, derivedExpressionNamed, derivedManualExpressionNamed, doNotUseOuterJoin, doUseOuterJoin, existingDerivedExpressionNamed, get, getAllowingNull, getFields, getForUpdateOfFields, getManualQueryKey, getOwnedTables, hasDerivedExpressions, isObjectExpression, isUsingOuterJoinForMultitableInheritance, newDerivedExpressionNamed, newManualDerivedExpressionNamed, postCopyIn, postCopyIn, setShouldUseOuterJoinForMultitableInheritance, shouldUseOuterJoin, shouldUseOuterJoinForMultitableInheritance, writeForUpdateOfFields
addDerivedField, addDerivedTable, assignAlias, assignAlias, clearAliases, copyCollection, existingDerivedField, existingDerivedTable, getAliasedField, getBaseExpression, getField, getField, getField, getMapping, getQueryKeyOrNull, getTable, getTable, getTableAliases, hasBeenAliased, hasBeenNormalized, hasDerivedFields, hasDerivedTables, isAttribute, isDataExpression, iterateOn, mappingCriteria, newDerivedField, newDerivedTable, printSQL, setBaseExpression, setHasBeenNormalized, setTableAliases, tableAliasesDescription, writeSubexpressionsTo
addDate, addDate, addMonths, addMonths, 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, anyOfAllowingNone, ascending, asciiValue, average, between, between, between, between, between, between, between, between, between, caseStatement, clone, cloneUsing, concat, containsAllKeyWords, containsAnyKeyWords, containsSubstring, containsSubstring, containsSubstringIgnoringCase, containsSubstringIgnoringCase, convertNodeToUseOuterJoin, convertToUseOuterJoin, copiedVersionFrom, count, create, create, createWithBaseLast, currentDate, currentDateDate, currentTime, currentTimeStamp, dateDifference, dateDifference, dateName, datePart, dateToString, decode, descending, detectExpression, difference, distinct, doesConform, doesConform, equal, equal, equal, equal, equal, equal, equal, equal, equal, equal, equalOuterJoin, equalOuterJoin, equalsIgnoreCase, equalsIgnoreCase, exists, existsNode, extract, extractPrimaryKeyValues, extractValue, from, fromConstant, fromLiteral, get, getAllowingNull, getClonedField, getFieldValue, getFunction, getFunction, getFunction, getFunction, getFunctionWithArguments, getName, getNumberVal, getOperator, getOperator, getParameter, getParameter, getParameter, getStringVal, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, hasAsOfClause, hexToRaw, ifNull, in, in, in, in, in, in, in, in, in, in, in, in, indexOf, isCompoundExpression, isConstantExpression, isEmpty, isFieldExpression, isFragment, isFunctionExpression, isLiteralExpression, isLogicalExpression, isNull, isParameterExpression, isQueryKeyExpression, isRelationExpression, isTableExpression, isValueExpression, lastDay, 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, 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, notNull, or, performOperator, postfixSQL, prefixSQL, printSQLWithoutConversion, ref, replace, replicate, replicate, resetCache, reverse, right, right, rightPad, rightPad, rightTrim, rightTrim, roundDate, selectIfOrderedBy, setLocalBase, setSelectIfOrderedBy, shallowClone, size, some, some, some, some, some, some, some, some, some, some, some, some, standardDeviation, subQuery, substring, substring, sum, toChar, toChar, toCharacter, toDate, toLowerCase, toNumber, toString, toString, toUpperCase, toUppercaseCasedWords, translate, trim, trim, truncateDate, twist, validateNode, value, value, value, value, value, value, value, value, value, value, valueFromObject, variance, writeField, writeFields
protected transient AbstractSession session
protected Class queryClass
protected SQLSelectStatement statement
protected DatabaseTable viewTable
protected DatabaseTable aliasedViewTable
protected boolean wasQueryClassSetInternally
protected boolean wasAdditionJoinCriteriaUsed
public ExpressionBuilder()
public ExpressionBuilder(Class queryClass)
public DatabaseTable aliasForTable(DatabaseTable table)
aliasForTable
in class DataExpression
public int assignTableAliasesStartingAt(int initialValue)
assignTableAliasesStartingAt
in class Expression
public String descriptionOfNodeType()
descriptionOfNodeType
in class Expression
public boolean doesNotRepresentAnObjectInTheQuery()
public DatabaseTable getAliasedViewTable()
public ExpressionBuilder getBuilder()
getBuilder
in class DataExpression
public ClassDescriptor getDescriptor()
getDescriptor
in class ObjectExpression
public Class getQueryClass()
public AbstractSession getSession()
getSession
in class Expression
public SQLSelectStatement getStatement()
public DatabaseTable getViewTable()
public boolean hasViewTable()
public boolean isExpressionBuilder()
isExpressionBuilder
in class Expression
public Expression normalize(ExpressionNormalizer normalizer)
normalize
in class DataExpression
public void printJava(ExpressionJavaPrinter printer)
printJava
in class Expression
public Expression rebuildOn(Expression newBase)
rebuildOn
in class Expression
Expression.cloneUsing(Expression newBase)
protected Expression registerIn(Dictionary alreadyDone)
registerIn
in class Expression
Expression.cloneUsing(Expression)
public void setQueryClass(Class queryClass)
public void setSession(AbstractSession session)
public void setStatement(SQLSelectStatement statement)
public void setViewTable(DatabaseTable theTable)
public void setWasAdditionJoinCriteriaUsed(boolean joinCriteriaUsed)
public Expression twistedForBaseAndContext(Expression newBase, Expression context)
twistedForBaseAndContext
in class Expression
newBase
- context
- public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean isObjectUnregistered)
valueFromObject
in class Expression
public boolean wasAdditionJoinCriteriaUsed()
public boolean wasQueryClassSetInternally()
public void writeDescriptionOn(BufferedWriter writer) throws IOException
writeDescriptionOn
in class Expression
IOException
Copyright © 2022. All rights reserved.