Class SQLExpression

    • Field Detail

      • stmt

        protected SQLStatement stmt
        The SQL statement that this is part of.
      • table

        protected SQLTable table
        Table in the SQL statement that this mapping applies to.
      • mapping

        protected JavaTypeMapping mapping
        Mapping for this expression, defining how it is get/set.
      • st

        protected final SQLText st
        The Statement Text representing the SQL for this expression.
      • lowestOperator

        protected org.datanucleus.store.query.expression.Expression.Operator lowestOperator
      • parameterName

        protected String parameterName
        Parameter name that this represents (if this is a parameter, "?" in JDBC).
    • Constructor Detail

      • SQLExpression

        protected SQLExpression​(SQLStatement stmt,
                                SQLTable table,
                                JavaTypeMapping mapping)
        Constructor for an SQL expression for a (field) mapping in a specified table.
        Parameters:
        stmt - The statement
        table - The table in the statement
        mapping - The mapping for the field
      • SQLExpression

        protected SQLExpression​(org.datanucleus.store.query.expression.Expression.MonadicOperator op,
                                SQLExpression expr1)
        Perform an operation "op" on expression "expr1".
        Parameters:
        op - operator
        expr1 - operand
      • SQLExpression

        protected SQLExpression​(SQLExpression expr1,
                                org.datanucleus.store.query.expression.Expression.DyadicOperator op,
                                SQLExpression expr2)
        Perform an operation "op" between "expr1" and "expr2".
        Parameters:
        expr1 - the first expression
        op - the operator between operands
        expr2 - the second expression
      • SQLExpression

        protected SQLExpression​(SQLStatement stmt,
                                JavaTypeMapping mapping,
                                String functionName,
                                List<SQLExpression> args,
                                List types)
        Generates statement as "FUNCTION_NAME(arg [AS type] [,argN [AS typeN]])". Number of objects in types (when supplied) is assumed to be the same as the number of arguments.
        Parameters:
        stmt - The statement to use for this expression
        mapping - Mapping to use
        functionName - Name of function
        args - SQLExpression list
        types - List of String/SQLExpression for the types of arguments
    • Method Detail

      • getLowestOperator

        public org.datanucleus.store.query.expression.Expression.Operator getLowestOperator()
      • getNumberOfSubExpressions

        public int getNumberOfSubExpressions()
      • isParameter

        public boolean isParameter()
      • getParameterName

        public String getParameterName()
      • setJavaTypeMapping

        public void setJavaTypeMapping​(JavaTypeMapping mapping)
      • getSQLTable

        public SQLTable getSQLTable()
      • toSQLText

        public SQLText toSQLText()
        Method to return the SQL form of this expression.
        Returns:
        The SQL
      • encloseInParentheses

        public SQLExpression encloseInParentheses()
        Method to request the enclosure of this expression within parentheses.
        Returns:
        the enclosed expression
      • and

        public BooleanExpression and​(SQLExpression expr)
        Conditional AND. Evaluates its right-hand operand only if the value of its left-hand operand is true.
        Parameters:
        expr - the right-hand operand
        Returns:
        the result value is true if both operand values are true; otherwise, the result is false.
      • eor

        public BooleanExpression eor​(SQLExpression expr)
        Exclusive OR
        Parameters:
        expr - the right-hand operand
        Returns:
        the result value is the bitwise exclusive OR of the operand values.
      • ior

        public BooleanExpression ior​(SQLExpression expr)
        Conditional OR. Evaluates its right-hand operand only if the value of its left-hand operand is false.
        Parameters:
        expr - the right-hand operand
        Returns:
        the result value is false if both operand values are false; otherwise, the result is true.
      • not

        public BooleanExpression not()
        Logical complement
        Returns:
        the result value is false if operand is true; otherwise, the result is true.
      • eq

        public BooleanExpression eq​(SQLExpression expr)
        Equality operator (equals to)
        Parameters:
        expr - the right-hand operand
        Returns:
        The type of an equality expression is a boolean
      • ne

        public BooleanExpression ne​(SQLExpression expr)
        Not equality operator (not equals to)
        Parameters:
        expr - the right-hand operand
        Returns:
        The type of an equality expression is a boolean
      • lt

        public BooleanExpression lt​(SQLExpression expr)
        Relational operator (lower than)
        Parameters:
        expr - the right-hand operand
        Returns:
        true if the value of the left-hand operand is less than the value of the right-hand operand, and otherwise is false.
      • le

        public BooleanExpression le​(SQLExpression expr)
        Relational operator (lower than or equals)
        Parameters:
        expr - the right-hand operand
        Returns:
        true if the value of the left-hand operand is less than or equal to the value of the right-hand operand, and otherwise is false.
      • gt

        public BooleanExpression gt​(SQLExpression expr)
        Relational operator (greater than)
        Parameters:
        expr - the right-hand operand
        Returns:
        true if the value of the left-hand operand is greater than the value of the right-hand operand, and otherwise is false.
      • ge

        public BooleanExpression ge​(SQLExpression expr)
        Relational operator (greater than or equals)
        Parameters:
        expr - the right-hand operand
        Returns:
        true if the value of the left-hand operand is greater than or equal the value of the right-hand operand, and otherwise is false.
      • in

        public BooleanExpression in​(SQLExpression expr,
                                    boolean not)
        In expression. Return true if this is contained by expr
        Parameters:
        expr - the right-hand expression
        not - Whether we really want "not in"
        Returns:
        true if the left-hand expression is contained by the right-hand expression. Otherwise the result is false.
      • add

        public SQLExpression add​(SQLExpression expr)
        Additive Operator. The binary + operator performs addition when applied to two operands of numeric type, producing the sum of the operands. If the type of either operand of a + operator is String, then the operation is string concatenation.
        Parameters:
        expr - the right-hand operand
        Returns:
        If one of the operands is String, the returned value is the string concatenation; The sum of two operands of numeric type. The left-hand operand is the minuend and the right-hand operand is the subtrahend;
      • sub

        public SQLExpression sub​(SQLExpression expr)
        Additive Operator. The binary - operator subtracts right-hand operand from left-hand operand.
        Parameters:
        expr - the right-hand operand
        Returns:
        The binary - operator performs subtraction when applied to two operands of numeric type producing the difference of its operands; the left-hand operand is the minuend and the right-hand operand is the subtrahend.
      • mul

        public SQLExpression mul​(SQLExpression expr)
        Multiplication Operator
        Parameters:
        expr - the right-hand operator
        Returns:
        The binary * operator performs multiplication, producing the product of its operands.
      • div

        public SQLExpression div​(SQLExpression expr)
        Division Operator. The left-hand operand is the dividend and the right-hand operand is the divisor.
        Parameters:
        expr - the right-hand operator
        Returns:
        The binary / operator performs division, producing the quotient of its operands
      • mod

        public SQLExpression mod​(SQLExpression expr)
        Remainder Operator. The left-hand operand is the dividend and the right-hand operand is the divisor.
        Parameters:
        expr - the right-hand operator
        Returns:
        The binary % operator is said to yield the remainder of its operands from an implied division
      • neg

        public SQLExpression neg()
        Unary Minus Operator
        Returns:
        the type of the unary minus expression is the promoted type of the operand.
      • com

        public SQLExpression com()
        Bitwise Complement Operator
        Returns:
        the type of the unary bitwise complement expression is the promoted type of the operand.
      • distinct

        public SQLExpression distinct()
        Distinct operator.
        Returns:
        converts the expression into "DISTINCT (expr)"
      • unDistinct

        public SQLExpression unDistinct()
        Method to remove a previously applied DISTINCT operator, to get back to the contained expression.
        Returns:
        This expression with DISTINCT removed
      • bitAnd

        public SQLExpression bitAnd​(SQLExpression expr)
        BITWISE AND operation.
        Parameters:
        expr - expression representing the bitset
        Returns:
        the bitwise AND expression
      • bitOr

        public SQLExpression bitOr​(SQLExpression expr)
        BITWISE OR operation.
        Parameters:
        expr - expression representing the bitset
        Returns:
        the bitwise OR expression
      • cast

        public SQLExpression cast​(SQLExpression expr)
        A cast expression converts, at run time, a value of one type to a similar value of another type; or confirms, at compile time, that the type of an expression is boolean; or checks, at run time, that a reference value refers to an object whose class is compatible with a specified reference type. The type of the operand expression must be converted to the type explicitly named by the cast operator.
        Parameters:
        expr - expression representing the type to cast to
        Returns:
        the converted value
      • is

        public BooleanExpression is​(SQLExpression expr,
                                    boolean not)
        An "is" (instanceOf) expression, providing a BooleanExpression whether this expression is an instanceof the provided type.
        Parameters:
        expr - the expression representing the type
        not - Whether we really want "!instanceof"
        Returns:
        Whether this expression is an instance of the provided type
      • invoke

        public SQLExpression invoke​(String methodName,
                                    List args)
        Invocation of a method on this expression.
        Parameters:
        methodName - name of the method to invoke
        args - Args to this method (if any)
        Returns:
        the converted value