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
| Modifier and Type | Field and Description |
|---|---|
| protected DatabaseTable | |
| protected Class | |
| protected transient AbstractSession | |
| protected SQLSelectStatement | |
| protected DatabaseTable | |
| protected boolean | |
| protected boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ExpressionBuilder(Class<?> queryClass)
ADVANCED: Create a new ExpressionBuilder representing instances of the argument class. |
| Modifier and Type | Method and Description |
|---|---|
| public DatabaseTable | aliasForTable(DatabaseTable table)
Overrides org. |
| public int | assignTableAliasesStartingAt(int initialValue)
Overrides org. |
| public String | descriptionOfNodeType()
Overrides org. |
| public 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. |
| public boolean | equals(Object
the reference object with which to compare. expression)Overrides org. |
| public DatabaseTable | |
| public ExpressionBuilder | getBuilder()
Overrides org. |
| public ClassDescriptor | getDescriptor()
Overrides org. |
| public ClassDescriptor | getLeafDescriptor(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session)
Overrides org. |
| public Class | |
| public AbstractSession | |
| public SQLSelectStatement | |
| public DatabaseTable | |
| public boolean | |
| public boolean | isExpressionBuilder()
Overrides org. |
| public Expression | normalize(ExpressionNormalizer normalizer)
Overrides org. |
| public void | printJava(ExpressionJavaPrinter printer)
Overrides org. |
| public Expression | rebuildOn(Expression newBase)
Implements abstract org. |
| protected Expression | registerIn(Map<K, V> alreadyDone)
Overrides org. |
| public void | resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)
Overrides org. |
| public void | |
| public void | setQueryClassAndDescriptor(Class<?> queryClass, ClassDescriptor descriptor)
INTERNAL: Set the class and descriptor which this node represents. |
| public void | setSession(AbstractSession session)
INTERNAL: Set the session in which we expect this expression to be translated. |
| public void | |
| public void | setViewTable(DatabaseTable theTable)
INTERNAL: This expression represents something read through a view table. |
| public 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. |
| public Expression | twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)
Overrides org. |
| public Object | valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean
true if object possibly not a clone, but is being
conformed against the unit of work cache. isObjectUnregistered)Overrides org. |
| public 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; |
| public boolean | wasQueryClassSetInternally()
INTERNAL: Returns true if TopLink set the query class as opposed to the customer. |
| public void | writeDescriptionOn(BufferedWriter writer)
Overrides org. |
| aliasedViewTable | back to summary |
|---|---|
| protected DatabaseTable aliasedViewTable | |
| queryClass | back to summary |
|---|---|
| protected Class<?> queryClass | |
| session | back to summary |
|---|---|
| protected transient AbstractSession session | |
| statement | back to summary |
|---|---|
| protected SQLSelectStatement statement | |
| viewTable | back to summary |
|---|---|
| protected DatabaseTable viewTable | |
| wasAdditionJoinCriteriaUsed | back to summary |
|---|---|
| protected boolean wasAdditionJoinCriteriaUsed | |
| wasQueryClassSetInternally | back to summary |
|---|---|
| protected boolean wasQueryClassSetInternally | |
| ExpressionBuilder | back to summary |
|---|---|
| public ExpressionBuilder() PUBLIC: Create a new ExpressionBuilder. | |
| ExpressionBuilder | back to summary |
|---|---|
| public ExpressionBuilder(Class<?> queryClass) ADVANCED: Create a new ExpressionBuilder representing instances of the argument class. This can be used for the purpose of parallel expressions. This is a type of query that searches on the relationship between to un-related objects. | |
| aliasForTable | back to summary |
|---|---|
| public DatabaseTable aliasForTable(DatabaseTable table) Overrides org. INTERNAL: Find the alias for a given table. Handle the special case where we are bogus and it should be aliased against our derived tables instead.
| |
| assignTableAliasesStartingAt | back to summary |
|---|---|
| public int assignTableAliasesStartingAt(int initialValue) Overrides org. INTERNAL: Assign aliases to any tables which I own. Start with t(initialValue), and return the new value of the counter , i.e. if initialValue is one and I have tables ADDRESS and EMPLOYEE I will assign them t1 and t2 respectively, and return 3.
| |
| descriptionOfNodeType | back to summary |
|---|---|
| public String descriptionOfNodeType() Overrides org. INTERNAL: Used for debug printing.
| |
| doesNotRepresentAnObjectInTheQuery | back to summary |
|---|---|
| public 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. Mostly this is the case where it's a data query in terms of tables, and the builder is only there to provide a base. It might be better to make tables able to serve as their own base, but it's very nice to have a known unique, shared base. In the meantime, this is a special case to make sure the builder doesn't get tables assigned. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object expression) Overrides org. INTERNAL: Return if the expression is equal to the other. This is used to allow dynamic expression's SQL to be cached.
| |
| getAliasedViewTable | back to summary |
|---|---|
| public DatabaseTable getAliasedViewTable() INTERNAL: | |
| getBuilder | back to summary |
|---|---|
| public ExpressionBuilder getBuilder() Overrides org. 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)
| |
| getDescriptor | back to summary |
|---|---|
| public ClassDescriptor getDescriptor() Overrides org. INTERNAL: Only usable after the session and class have been set. Return the descriptor for the class this node represents.
| |
| getLeafDescriptor | back to summary |
|---|---|
| public ClassDescriptor getLeafDescriptor(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session) Overrides org. INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.
| |
| getQueryClass | back to summary |
|---|---|
| public Class INTERNAL: | |
| getSession | back to summary |
|---|---|
| public AbstractSession getSession() Overrides org. INTERNAL:
| |
| getStatement | back to summary |
|---|---|
| public SQLSelectStatement getStatement() INTERNAL: Return the statement that expression is for. This is used for the context in subselects. | |
| getViewTable | back to summary |
|---|---|
| public DatabaseTable getViewTable() INTERNAL: | |
| hasViewTable | back to summary |
|---|---|
| public boolean hasViewTable() INTERNAL: | |
| isExpressionBuilder | back to summary |
|---|---|
| public boolean isExpressionBuilder() Overrides org. INTERNAL:
| |
| normalize | back to summary |
|---|---|
| public Expression normalize(ExpressionNormalizer normalizer) Overrides org. INTERNAL: Normalize the expression into a printable structure. Any joins must be added to form a new root.
| |
| printJava | back to summary |
|---|---|
| public void printJava(ExpressionJavaPrinter printer) Overrides org. INTERNAL: Print java
| |
| rebuildOn | back to summary |
|---|---|
| public Expression rebuildOn(Expression newBase) Implements abstract org. INTERNAL: This expression is built on a different base than the one we want. Rebuild it and return the root of the new tree This assumes that the original expression has only a single builder.
| |
| registerIn | back to summary |
|---|---|
| protected Expression registerIn(Map<K, V> alreadyDone) Overrides org. INTERNAL: Override Expression.registerIn to check if the new base expression has already been provided for the clone.
| |
| resetPlaceHolderBuilder | back to summary |
|---|---|
| public void resetPlaceHolderBuilder(ExpressionBuilder queryBuilder) Overrides org. INTERNAL: Search the tree for any expressions (like SubSelectExpressions) that have been built using a builder that is not attached to the query. This happens in case of an Exists call using a new ExpressionBuilder(). This builder needs to be replaced with one from the query.
| |
| setQueryClass | back to summary |
|---|---|
| public void setQueryClass(Class<?> queryClass) INTERNAL: Set the class which this node represents. | |
| setQueryClassAndDescriptor | back to summary |
|---|---|
| public void setQueryClassAndDescriptor(Class<?> queryClass, ClassDescriptor descriptor) INTERNAL: Set the class and descriptor which this node represents. | |
| setSession | back to summary |
|---|---|
| public void setSession(AbstractSession session) INTERNAL: Set the session in which we expect this expression to be translated. Stored session shall always be root session. | |
| setStatement | back to summary |
|---|---|
| public void setStatement(SQLSelectStatement statement) INTERNAL: Set the statement that expression is for. This is used for the context in subselects. | |
| setViewTable | back to summary |
|---|---|
| public void setViewTable(DatabaseTable theTable) INTERNAL: This expression represents something read through a view table. | |
| setWasAdditionJoinCriteriaUsed | back to summary |
|---|---|
| public 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. This will prevent TopLink from adding it again at normalization | |
| twistedForBaseAndContext | back to summary |
|---|---|
| public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase) Overrides org. INTERNAL: Rebuild myself against the base, with the values of parameters supplied by the context expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) into part of some larger expression. You normally would not call this directly, instead calling twist See the comment there for more details.
| |
| valueFromObject | back to summary |
|---|---|
| public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) Overrides org. INTERNAL: The expression builder represent the entire object, just return it.
| |
| wasAdditionJoinCriteriaUsed | back to summary |
|---|---|
| public 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; | |
| wasQueryClassSetInternally | back to summary |
|---|---|
| public boolean wasQueryClassSetInternally() INTERNAL: Returns true if TopLink set the query class as opposed to the customer. This is important in determining if this Expression should be treated as a parallel expression during normalization | |
| writeDescriptionOn | back to summary |
|---|---|
| public void writeDescriptionOn(BufferedWriter writer) throws IOException Overrides org. INTERNAL: For debug printing purposes.
| |