Package org.datanucleus.store.rdbms.sql.expression

Examples of org.datanucleus.store.rdbms.sql.expression.BooleanExpression


                    // Any pattern expression cannot be a parameter here
                    SQLLiteral substrLit = (SQLLiteral)substrExpr;
                    stmt.getQueryGenerator().useParameterExpressionAsLiteral(substrLit);
                    if (substrLit.getValue() == null)
                    {
                        return new BooleanExpression(expr, Expression.OP_LIKE,
                            ExpressionUtils.getEscapedPatternExpression(substrExpr));
                    }
                }
                SQLExpression likeSubstrExpr = new StringLiteral(stmt,
                    expr.getJavaTypeMapping(), '%', null);
                return new BooleanExpression(expr, Expression.OP_LIKE,
                    ExpressionUtils.getEscapedPatternExpression(substrExpr).add(likeSubstrExpr));
            }
            else
            {
                // Create a new StringExpression and manually update its SQL
                if (substrExpr.isParameter())
                {
                    // Any pattern expression cannot be a parameter here
                    SQLLiteral substrLit = (SQLLiteral)substrExpr;
                    stmt.getQueryGenerator().useParameterExpressionAsLiteral(substrLit);
                    if (substrLit.getValue() == null)
                    {
                        return new BooleanExpression(expr, Expression.OP_LIKE,
                            ExpressionUtils.getEscapedPatternExpression(substrExpr));
                    }
                }
                SQLExpression likeSubstrExpr = new StringLiteral(stmt,
                    expr.getJavaTypeMapping(), '%', null);
                return new BooleanExpression(expr, Expression.OP_LIKE,
                    ExpressionUtils.getEscapedPatternExpression(substrExpr).add(likeSubstrExpr));
            }
        }
    }
View Full Code Here


            {
                return exprFactory.newLiteral(stmt, m, true).eq(exprFactory.newLiteral(stmt, m, false));
            }

            // TODO If elemExpr is a parameter and collExpr is derived from a parameter ?
            BooleanExpression bExpr = null;
            List<SQLExpression> elementExprs = lit.getElementExpressions();
            for (int i=0; i<elementExprs.size(); i++)
            {
                SQLExpression arrElemExpr = elementExprs.get(i);
                if (bExpr == null)
                {
                    bExpr = arrElemExpr.eq(elemExpr);
                }
                else
                {
                    bExpr = bExpr.ior(arrElemExpr.eq(elemExpr));
                }
            }
            bExpr.encloseInParentheses();
            return bExpr;
        }
        else if (arrExpr.getElementExpressions() != null)
        {
            if (elemExpr instanceof UnboundExpression)
            {
                Class elemCls = clr.classForName(arrExpr.getJavaTypeMapping().getType()).getComponentType();
                elemExpr = stmt.getQueryGenerator().bindVariable((UnboundExpression)elemExpr, elemCls);
            }

            // Array defined in query that has some expressions for elements, so just do OR chain
            BooleanExpression bExpr = null;
            List<SQLExpression> elementExprs = arrExpr.getElementExpressions();
            for (int i=0; i<elementExprs.size(); i++)
            {
                SQLExpression arrElemExpr = elementExprs.get(i);
                if (bExpr == null)
                {
                    bExpr = arrElemExpr.eq(elemExpr);
                }
                else
                {
                    bExpr = bExpr.ior(arrElemExpr.eq(elemExpr));
                }
            }
            bExpr.encloseInParentheses();
            return bExpr;
        }
        else
        {
            // TODO Support inner join variant
View Full Code Here

    }

    protected BooleanExpression getExpressionForStringExpressionInput(SQLExpression expr,
            SQLExpression regExpr, SQLExpression escapeExpr)
    {
        BooleanExpression likeExpr = getBooleanLikeExpression(expr, regExpr, escapeExpr);
        return likeExpr;
    }
View Full Code Here

    }

    protected BooleanExpression getBooleanLikeExpression(SQLExpression expr, SQLExpression regExpr,
            SQLExpression escapeExpr)
    {
        BooleanExpression likeExpr = new BooleanExpression(stmt, exprFactory.getMappingForType(boolean.class, false));
        SQLText sql= likeExpr.toSQLText();
        sql.clearStatement();
        if (Expression.OP_LIKE.isHigherThanLeftSide(expr.getLowestOperator()))
        {
            sql.append("(").append(expr).append(")");
        }
View Full Code Here

            if (args.size() == 2)
            {
                NumericExpression numExpr = (NumericExpression) args.get(1);
                funcArgs.add(substrExpr);
                funcArgs.add(expr);
                return new BooleanExpression(
                    new StringExpression(stmt, getMappingForClass(int.class), "CHARINDEX", funcArgs), Expression.OP_EQ,
                        one.add(numExpr));
            }
            else
            {
                funcArgs.add(substrExpr);
                funcArgs.add(expr);
                return new BooleanExpression(
                    new StringExpression(stmt, getMappingForClass(int.class), "CHARINDEX", funcArgs), Expression.OP_EQ, one);
            }
        }
    }
View Full Code Here

           throw new NucleusUserException("Cannot use SQL_boolean() without string argument");
        }
        String sql = (String)((StringLiteral)expr).getValue();

        JavaTypeMapping m = exprFactory.getMappingForType(boolean.class, false);
        BooleanExpression retExpr = new BooleanExpression(stmt, m, sql);
        return retExpr;
    }
View Full Code Here

                return new InExpression(elemExpr, exprs);
            }
            else
            {
                // Return "elem == val1 || elem == val2 || elem == val3 ..."
                BooleanExpression bExpr = null;
                for (int i=0; i<collElementExprs.size(); i++)
                {
                    if (bExpr == null)
                    {
                        bExpr = (collElementExprs.get(i)).eq(elemExpr);
                    }
                    else
                    {
                        bExpr = bExpr.ior((collElementExprs.get(i)).eq(elemExpr));
                    }
                }
                bExpr.encloseInParentheses();
                return bExpr;
            }
        }
        else
        {
View Full Code Here

TOP

Related Classes of org.datanucleus.store.rdbms.sql.expression.BooleanExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.