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

Examples of org.datanucleus.store.rdbms.sql.expression.SQLExpression$ColumnExpressionList


                "StringExpression/CharacterExpression"));
        }
        else
        {
            // {strExpr}.translate(strExpr1, strExpr2)
            SQLExpression strExpr1 = (SQLExpression)args.get(0);
            SQLExpression strExpr2 = (SQLExpression)args.get(1);
            if (!(strExpr1 instanceof StringExpression) &&
                !(strExpr1 instanceof CharacterExpression))
            {
                throw new NucleusException(LOCALISER.msg("060003", "replaceAll", "StringExpression", 1,
                    "StringExpression/CharacterExpression"));
View Full Code Here


            throw new NucleusException(LOCALISER.msg("060001", "getMinute()", expr));
        }

        RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
        JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
        SQLExpression mi = exprFactory.newLiteral(stmt, mapping, "MI");

        ArrayList funcArgs = new ArrayList();
        funcArgs.add(expr);
        funcArgs.add(mi);
        ArrayList funcArgs2 = new ArrayList();
View Full Code Here

        if (args == null || args.size() == 0)
        {
            throw new NucleusUserException("Cannot invoke Math.ceil without an argument");
        }

        SQLExpression expr = (SQLExpression)args.get(0);
        if (expr == null)
        {
            return new NullLiteral(stmt, null, null, null);
        }
        else if (expr instanceof SQLLiteral)
        {
            if (expr instanceof ByteLiteral)
            {
                int originalValue = ((BigInteger) ((ByteLiteral) expr).getValue()).intValue();
                BigInteger absValue = new BigInteger(String.valueOf(Math.ceil(originalValue)));
                return new ByteLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            else if (expr instanceof IntegerLiteral)
            {
                int originalValue = ((Number) ((IntegerLiteral) expr).getValue()).intValue();
                Double absValue = new Double(originalValue);
                return new FloatingPointLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            else if (expr instanceof FloatingPointLiteral)
            {
                double originalValue = ((BigDecimal) ((FloatingPointLiteral) expr).getValue()).doubleValue();
                Double absValue = new Double(Math.ceil(originalValue));
                return new FloatingPointLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            throw new IllegalExpressionOperationException("Math.ceil()", expr);
        }
        else
        {
View Full Code Here

        if (args == null || args.size() == 0)
        {
            throw new NucleusUserException("Cannot invoke Math.acos without an argument");
        }

        SQLExpression expr = (SQLExpression)args.get(0);
        if (expr == null)
        {
            return new NullLiteral(stmt, null, null, null);
        }
        else if (expr instanceof SQLLiteral)
        {
            if (expr instanceof ByteLiteral)
            {
                int originalValue = ((BigInteger) ((ByteLiteral) expr).getValue()).intValue();
                BigInteger absValue = new BigInteger(String.valueOf(Math.acos(originalValue)));
                return new ByteLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            else if (expr instanceof IntegerLiteral)
            {
                int originalValue = ((Number) ((IntegerLiteral) expr).getValue()).intValue();
                Double absValue = new Double(Math.acos(originalValue));
                return new FloatingPointLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            else if (expr instanceof FloatingPointLiteral)
            {
                double originalValue = ((BigDecimal) ((FloatingPointLiteral) expr).getValue()).doubleValue();
                Double absValue = new Double(Math.acos(originalValue));
                return new FloatingPointLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            throw new IllegalExpressionOperationException("Math.acos()", expr);
        }
        else
        {
View Full Code Here

            }
            JavaTypeMapping m = null;
            if (args.get(0) instanceof SQLExpression)
            {
                // Use same java type as the argument
                SQLExpression argExpr = (SQLExpression)args.get(0);
                Class cls = argExpr.getJavaTypeMapping().getJavaType();
                if (cls == Integer.class || cls == Short.class || cls == Long.class)
                {
                    m = getMappingForClass(Long.class);
                }
                else if (Number.class.isAssignableFrom(cls))
                {
                    m = getMappingForClass(argExpr.getJavaTypeMapping().getJavaType());
                }
                else
                {
                    throw new NucleusUserException("Cannot perform SUM on " + expr + " of type " + cls.getName());
                }
View Full Code Here

        // Use Derby "NUCLEUS_MATCHES" function
        List funcArgs = new ArrayList();
        funcArgs.add(expr);
        funcArgs.add(argExpr);
        JavaTypeMapping m = exprFactory.getMappingForType(BigInteger.class, false);
        SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);
        return new NumericExpression(stmt, m, "NUCLEUS_MATCHES", funcArgs).eq(one);
    }
View Full Code Here

                "StringExpression/CharacterExpression/ParameterLiteral"));
        }
        else
        {
            // {stringExpr}.indexOf(strExpr1 [,numExpr2])
            SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);

            ArrayList funcArgs = new ArrayList();
            funcArgs.add(expr);

            List funcArgs2 = new ArrayList();
            SQLExpression substrExpr = (SQLExpression)args.get(0);
            if (!(substrExpr instanceof StringExpression) &&
                !(substrExpr instanceof CharacterExpression) &&
                !(substrExpr instanceof ParameterLiteral))
            {
                throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 0,
                    "StringExpression/CharacterExpression/ParameterLiteral"));
            }
            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))
                {
                    throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 1,
                        "NumericExpression"));
                }
View Full Code Here

                    throw new NucleusUserException(
                        "Cannot perform Collection.isEmpty when the collection<Non-Persistable> is not in a join table");
                }
            }

            SQLExpression sizeExpr =
                exprFactory.invokeMethod(stmt, Collection.class.getName(), "size", expr, args);
            JavaTypeMapping mapping = exprFactory.getMappingForType(Integer.class, true);
            SQLExpression zeroExpr = exprFactory.newLiteral(stmt, mapping, 0);
            return sizeExpr.eq(zeroExpr);
        }
    }
View Full Code Here

        if (args == null || args.size() == 0)
        {
            throw new NucleusUserException("Cannot invoke Math.sin without an argument");
        }

        SQLExpression expr = (SQLExpression)args.get(0);
        if (expr == null)
        {
            return new NullLiteral(stmt, null, null, null);
        }
        else if (expr instanceof SQLLiteral)
        {
            if (expr instanceof ByteLiteral)
            {
                int originalValue = ((BigInteger) ((ByteLiteral) expr).getValue()).intValue();
                BigInteger absValue = new BigInteger(String.valueOf(Math.sin(originalValue)));
                return new ByteLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            else if (expr instanceof IntegerLiteral)
            {
                int originalValue = ((Number) ((IntegerLiteral) expr).getValue()).intValue();
                Double absValue = new Double(Math.sin(originalValue));
                return new FloatingPointLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            else if (expr instanceof FloatingPointLiteral)
            {
                double originalValue = ((BigDecimal) ((FloatingPointLiteral) expr).getValue()).doubleValue();
                Double absValue = new Double(Math.sin(originalValue));
                return new FloatingPointLiteral(stmt, expr.getJavaTypeMapping(), absValue, null);
            }
            throw new IllegalExpressionOperationException("Math.sin()", expr);
        }
        else
        {
View Full Code Here

                "NumericExpression/IntegerLiteral/ParameterLiteral"));
        }
        else if (args.size() == 1)
        {
            // {stringExpr}.substring(numExpr1)
            SQLExpression startExpr = (SQLExpression)args.get(0);
            if (!(startExpr instanceof NumericExpression) &&
                !(startExpr instanceof IntegerLiteral) &&
                !(startExpr instanceof ParameterLiteral))
            {
                throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 0,
                    "NumericExpression/IntegerLiteral/ParameterLiteral"));
            }

            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));
View Full Code Here

TOP

Related Classes of org.datanucleus.store.rdbms.sql.expression.SQLExpression$ColumnExpressionList

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.