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

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


        List args = new ArrayList();
        args.add(expr);
        List types = new ArrayList();
        types.add("CHAR(4000)");
        return new StringExpression(expr.getSQLStatement(), m, "CAST", args, types);
    }
View Full Code Here


        RDBMSStoreManager storeMgr = expr.getSQLStatement().getRDBMSManager();
        JavaTypeMapping m = storeMgr.getSQLExpressionFactory().getMappingForType(String.class, false);
        ArrayList args = new ArrayList();
        args.add(expr);
        args.add(expr2);
        return new StringExpression(expr.getSQLStatement(), m, "CONCAT", args);
    }
View Full Code Here

        List types = new ArrayList();
        types.add("VARCHAR(4000)");

        List argsOp1 = new ArrayList();
        argsOp1.add(expr);
        SQLExpression firstExpr = new StringExpression(expr.getSQLStatement(), m, "CAST", argsOp1, types).encloseInParentheses();

        List argsOp2 = new ArrayList();
        argsOp2.add(expr2);
        SQLExpression secondExpr = new StringExpression(expr.getSQLStatement(), m, "CAST", argsOp2, types).encloseInParentheses();

        StringExpression concatExpr = new StringExpression(expr.getSQLStatement(), null, null);
        SQLText sql = concatExpr.toSQLText();
        sql.clearStatement();
        sql.append(firstExpr);
        sql.append("||");
        sql.append(secondExpr);

        List args = new ArrayList();
        args.add(concatExpr);

        return new StringExpression(expr.getSQLStatement(), m, "CAST", args, types);
    }
View Full Code Here

        List args = new ArrayList();
        args.add(expr);
        List types = new ArrayList();
        types.add("VARCHAR(4000)");
        return new StringExpression(expr.getSQLStatement(), m, "CAST", args, types);
    }
View Full Code Here

        {
            throw new NucleusException(LOCALISER.msg("060003", "endsWith", "StringExpression", 0,
                "StringExpression/CharacterExpression/ParameterLiteral"));
        }

        StringExpression strExpr1 = (StringExpression)expr;
        StringExpression strExpr2 = (StringExpression)args.get(0);
        SQLExpression str1Upper = strExpr1.invoke("toUpperCase", null);
        SQLExpression str2Upper = strExpr2.invoke("toUpperCase", null);
        return str1Upper.eq(str2Upper);
    }
View Full Code Here

            List<SQLExpression> newArgs = new ArrayList<SQLExpression>(3);
            newArgs.add(expr);
            newArgs.add(strExpr1);
            newArgs.add(strExpr2);
            JavaTypeMapping mapping = exprFactory.getMappingForType(String.class, false);
            return new StringExpression(stmt, mapping, "replace", newArgs);
        }
    }
View Full Code Here

        ArrayList funcArgs = new ArrayList();
        funcArgs.add(expr);
        funcArgs.add(mi);
        ArrayList funcArgs2 = new ArrayList();
        funcArgs2.add(new StringExpression(stmt, mapping, "TO_CHAR", funcArgs));
        return new NumericExpression(stmt, getMappingForClass(int.class), "TO_NUMBER", funcArgs2);
    }
View Full Code Here

            }
            funcArgs2.add(substrExpr);

            List types = new ArrayList();
            types.add("VARCHAR(4000)"); // max 4000 according DB2 docs
            funcArgs.add(new StringExpression(stmt, getMappingForClass(String.class), "CAST", funcArgs2, types));

            if (args.size() == 2)
            {
                SQLExpression fromExpr = (SQLExpression)args.get(1);
                if (!(fromExpr instanceof NumericExpression))
View Full Code Here

            SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);

            ArrayList funcArgs = new ArrayList();
            funcArgs.add(expr);
            funcArgs.add(startExpr.add(one));
            return new StringExpression(stmt, getMappingForClass(String.class), "SUBSTRING", funcArgs);
        }
        else
        {
            // {stringExpr}.substring(numExpr1, numExpr2)
            SQLExpression startExpr = (SQLExpression)args.get(0);
            if (!(startExpr instanceof NumericExpression))
            {
                throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 0,
                    "NumericExpression"));
            }
            SQLExpression endExpr = (SQLExpression)args.get(1);
            if (!(endExpr instanceof NumericExpression))
            {
                throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 1,
                    "NumericExpression"));
            }

            SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);

            ArrayList funcArgs = new ArrayList();
            funcArgs.add(expr);
            funcArgs.add(startExpr.add(one));
            funcArgs.add(endExpr.sub(startExpr));
            return new StringExpression(stmt, getMappingForClass(String.class), "SUBSTRING", funcArgs);
        }
    }
View Full Code Here

        }
        else
        {
            ArrayList funcArgs = new ArrayList();
            funcArgs.add(expr);
            StringExpression strExpr =
                new StringExpression(stmt, getMappingForClass(String.class), "RTRIM", funcArgs);
            args.clear();
            args.add(strExpr);
            return new StringExpression(stmt, getMappingForClass(String.class), "LTRIM", args);
        }
    }
View Full Code Here

TOP

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

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.