Class ExpressionBuilder

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class ExpressionBuilder
    extends org.eclipse.persistence.internal.expressions.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.


            ExpressionBuilder employee = new ExpressionBuilder();
            >> equivalent Java code: (employee.getFirstName().equals("Bob")) && (employee.getLastName().equals("Smith"))
            >> equivalent SQL: (F_NAME = 'Bob') AND (L_NAME = 'Smith')
    See Also:
    Expression, Serialized Form
    • Field Detail

      • session

        protected transient org.eclipse.persistence.internal.sessions.AbstractSession session
      • queryClass

        protected Class queryClass
      • statement

        protected org.eclipse.persistence.internal.expressions.SQLSelectStatement statement
      • viewTable

        protected org.eclipse.persistence.internal.helper.DatabaseTable viewTable
      • aliasedViewTable

        protected org.eclipse.persistence.internal.helper.DatabaseTable aliasedViewTable
      • wasQueryClassSetInternally

        protected boolean wasQueryClassSetInternally
      • wasAdditionJoinCriteriaUsed

        protected boolean wasAdditionJoinCriteriaUsed
    • Constructor Detail

      • ExpressionBuilder

        public ExpressionBuilder()
        PUBLIC: Create a new ExpressionBuilder.
      • ExpressionBuilder

        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.
    • Method Detail

      • equals

        public boolean equals​(Object expression)
        INTERNAL: Return if the expression is equal to the other. This is used to allow dynamic expression's SQL to be cached.
        equals in class org.eclipse.persistence.internal.expressions.ObjectExpression
      • aliasForTable

        public org.eclipse.persistence.internal.helper.DatabaseTable aliasForTable​(org.eclipse.persistence.internal.helper.DatabaseTable table)
        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.
        aliasForTable in class org.eclipse.persistence.internal.expressions.DataExpression
      • assignTableAliasesStartingAt

        public int assignTableAliasesStartingAt​(int initialValue)
        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.
        assignTableAliasesStartingAt in class org.eclipse.persistence.internal.expressions.ObjectExpression
      • doesNotRepresentAnObjectInTheQuery

        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.
      • getAliasedViewTable

        public org.eclipse.persistence.internal.helper.DatabaseTable getAliasedViewTable()
      • getBuilder

        public 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)
        getBuilder in class org.eclipse.persistence.internal.expressions.BaseExpression
      • getDescriptor

        public ClassDescriptor getDescriptor()
        INTERNAL: Only usable after the session and class have been set. Return the descriptor for the class this node represents.
        getDescriptor in class org.eclipse.persistence.internal.expressions.ObjectExpression
      • getQueryClass

        public Class getQueryClass()
      • getSession

        public org.eclipse.persistence.internal.sessions.AbstractSession getSession()
        getSession in class Expression
      • getStatement

        public org.eclipse.persistence.internal.expressions.SQLSelectStatement getStatement()
        INTERNAL: Return the statement that expression is for. This is used for the context in subselects.
      • getViewTable

        public org.eclipse.persistence.internal.helper.DatabaseTable getViewTable()
      • hasViewTable

        public boolean hasViewTable()
      • normalize

        public Expression normalize​(org.eclipse.persistence.internal.expressions.ExpressionNormalizer normalizer)
        INTERNAL: Normalize the expression into a printable structure. Any joins must be added to form a new root.
        normalize in class org.eclipse.persistence.internal.expressions.DataExpression
      • printJava

        public void printJava​(org.eclipse.persistence.internal.expressions.ExpressionJavaPrinter printer)
        INTERNAL: Print java
        printJava in class Expression
      • resetPlaceHolderBuilder

        public 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. This happens in case of an Exists call using a new ExpressionBuilder(). This builder needs to be replaced with one from the query.
        resetPlaceHolderBuilder in class org.eclipse.persistence.internal.expressions.BaseExpression
      • setQueryClass

        public void setQueryClass​(Class queryClass)
        INTERNAL: Set the class which this node represents.
      • setQueryClassAndDescriptor

        public void setQueryClassAndDescriptor​(Class queryClass,
                                               ClassDescriptor descriptor)
        INTERNAL: Set the class and descriptor which this node represents.
      • setSession

        public void setSession​(org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Set the session in which we expect this expression to be translated. Stored session shall always be root session.
      • setStatement

        public void setStatement​(org.eclipse.persistence.internal.expressions.SQLSelectStatement statement)
        INTERNAL: Set the statement that expression is for. This is used for the context in subselects.
      • setViewTable

        public void setViewTable​(org.eclipse.persistence.internal.helper.DatabaseTable theTable)
        INTERNAL: This expression represents something read through a view table.
      • setWasAdditionJoinCriteriaUsed

        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

        public Expression twistedForBaseAndContext​(Expression newBase,
                                                   Expression context,
                                                   Expression oldBase)
        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.
        twistedForBaseAndContext in class Expression
      • valueFromObject

        public Object valueFromObject​(Object object,
                                      org.eclipse.persistence.internal.sessions.AbstractSession session,
                                      org.eclipse.persistence.internal.sessions.AbstractRecord translationRow,
                                      int valueHolderPolicy,
                                      boolean isObjectUnregistered)
        INTERNAL: The expression builder represent the entire object, just return it.
        valueFromObject in class Expression
        isObjectUnregistered - true if object possibly not a clone, but is being conformed against the unit of work cache.
      • wasAdditionJoinCriteriaUsed

        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

        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