Search in sources :

Example 1 with StringExpression

use of org.datanucleus.store.rdbms.sql.expression.StringExpression in project datanucleus-rdbms by datanucleus.

the class QueryToSQLMapper method processCaseExpression.

protected Object processCaseExpression(CaseExpression expr, SQLExpression typeExpr) {
    processingCase = true;
    try {
        List<ExpressionPair> conditions = expr.getConditions();
        Iterator<ExpressionPair> whenExprIter = conditions.iterator();
        SQLExpression[] whenSqlExprs = new SQLExpression[conditions.size()];
        SQLExpression[] actionSqlExprs = new SQLExpression[conditions.size()];
        boolean numericCase = false;
        boolean booleanCase = false;
        boolean stringCase = false;
        boolean typeSet = false;
        if (typeExpr != null) {
            if (typeExpr instanceof NumericExpression) {
                numericCase = true;
                typeSet = true;
            } else if (typeExpr instanceof BooleanExpression) {
                booleanCase = true;
                typeSet = true;
            } else if (typeExpr instanceof StringExpression) {
                stringCase = true;
                typeSet = true;
            }
        }
        int i = 0;
        while (whenExprIter.hasNext()) {
            ExpressionPair pair = whenExprIter.next();
            Expression whenExpr = pair.getWhenExpression();
            whenExpr.evaluate(this);
            whenSqlExprs[i] = stack.pop();
            if (!(whenSqlExprs[i] instanceof BooleanExpression)) {
                throw new QueryCompilerSyntaxException("IF/ELSE conditional expression should return boolean but doesn't : " + expr);
            }
            Expression actionExpr = pair.getActionExpression();
            actionExpr.evaluate(this);
            actionSqlExprs[i] = stack.pop();
            if (!typeSet) {
                if (actionSqlExprs[i] instanceof NumericExpression) {
                    numericCase = true;
                    typeSet = true;
                } else if (actionSqlExprs[i] instanceof BooleanExpression) {
                    booleanCase = true;
                    typeSet = true;
                } else if (actionSqlExprs[i] instanceof StringExpression) {
                    stringCase = true;
                    typeSet = true;
                }
            }
            i++;
        }
        Expression elseExpr = expr.getElseExpression();
        elseExpr.evaluate(this);
        SQLExpression elseActionSqlExpr = stack.pop();
        // Check that all action sql expressions are consistent
        for (int j = 1; j < actionSqlExprs.length; j++) {
            if (!checkCaseExpressionsConsistent(actionSqlExprs[0], actionSqlExprs[j])) {
                throw new QueryCompilerSyntaxException("IF/ELSE action expression " + actionSqlExprs[j] + " is of different type to first action " + actionSqlExprs[0] + " - must be consistent");
            }
        }
        if (!checkCaseExpressionsConsistent(actionSqlExprs[0], elseActionSqlExpr)) {
            throw new QueryCompilerSyntaxException("IF/ELSE action expression " + elseActionSqlExpr + " is of different type to first action " + actionSqlExprs[0] + " - must be consistent");
        }
        SQLExpression caseSqlExpr = null;
        if (numericCase) {
            caseSqlExpr = new org.datanucleus.store.rdbms.sql.expression.CaseNumericExpression(whenSqlExprs, actionSqlExprs, elseActionSqlExpr);
        } else if (booleanCase) {
            caseSqlExpr = new org.datanucleus.store.rdbms.sql.expression.CaseBooleanExpression(whenSqlExprs, actionSqlExprs, elseActionSqlExpr);
        } else if (stringCase) {
            caseSqlExpr = new org.datanucleus.store.rdbms.sql.expression.CaseStringExpression(whenSqlExprs, actionSqlExprs, elseActionSqlExpr);
        } else {
            caseSqlExpr = new org.datanucleus.store.rdbms.sql.expression.CaseExpression(whenSqlExprs, actionSqlExprs, elseActionSqlExpr);
        }
        stack.push(caseSqlExpr);
        return caseSqlExpr;
    } finally {
        processingCase = false;
    }
}
Also used : SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) NumericExpression(org.datanucleus.store.rdbms.sql.expression.NumericExpression) BooleanExpression(org.datanucleus.store.rdbms.sql.expression.BooleanExpression) CaseExpression(org.datanucleus.query.expression.CaseExpression) BooleanSubqueryExpression(org.datanucleus.store.rdbms.sql.expression.BooleanSubqueryExpression) StringExpression(org.datanucleus.store.rdbms.sql.expression.StringExpression) JoinExpression(org.datanucleus.query.expression.JoinExpression) NumericSubqueryExpression(org.datanucleus.store.rdbms.sql.expression.NumericSubqueryExpression) StringSubqueryExpression(org.datanucleus.store.rdbms.sql.expression.StringSubqueryExpression) ClassExpression(org.datanucleus.query.expression.ClassExpression) InvokeExpression(org.datanucleus.query.expression.InvokeExpression) MapExpression(org.datanucleus.store.rdbms.sql.expression.MapExpression) SubqueryExpression(org.datanucleus.query.expression.SubqueryExpression) NewObjectExpression(org.datanucleus.store.rdbms.sql.expression.NewObjectExpression) TemporalSubqueryExpression(org.datanucleus.store.rdbms.sql.expression.TemporalSubqueryExpression) BooleanExpression(org.datanucleus.store.rdbms.sql.expression.BooleanExpression) OrderExpression(org.datanucleus.query.expression.OrderExpression) PrimaryExpression(org.datanucleus.query.expression.PrimaryExpression) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) UnboundExpression(org.datanucleus.store.rdbms.sql.expression.UnboundExpression) TemporalExpression(org.datanucleus.store.rdbms.sql.expression.TemporalExpression) ArrayExpression(org.datanucleus.query.expression.ArrayExpression) ResultAliasExpression(org.datanucleus.store.rdbms.sql.expression.ResultAliasExpression) CreatorExpression(org.datanucleus.query.expression.CreatorExpression) Expression(org.datanucleus.query.expression.Expression) TypeExpression(org.datanucleus.query.expression.TypeExpression) NumericExpression(org.datanucleus.store.rdbms.sql.expression.NumericExpression) CollectionExpression(org.datanucleus.store.rdbms.sql.expression.CollectionExpression) DyadicExpression(org.datanucleus.query.expression.DyadicExpression) ParameterExpression(org.datanucleus.query.expression.ParameterExpression) ColumnExpression(org.datanucleus.store.rdbms.sql.expression.ColumnExpression) VariableExpression(org.datanucleus.query.expression.VariableExpression) StringExpression(org.datanucleus.store.rdbms.sql.expression.StringExpression) QueryCompilerSyntaxException(org.datanucleus.store.query.QueryCompilerSyntaxException) ExpressionPair(org.datanucleus.query.expression.CaseExpression.ExpressionPair)

Example 2 with StringExpression

use of org.datanucleus.store.rdbms.sql.expression.StringExpression in project datanucleus-rdbms by datanucleus.

the class MapContainsKeyMethod method getExpression.

/* (non-Javadoc)
     * @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
     */
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
    if (args == null || args.size() == 0 || args.size() > 1) {
        throw new NucleusException(Localiser.msg("060016", "containsKey", "MapExpression", 1));
    }
    MapExpression mapExpr = (MapExpression) expr;
    SQLExpression keyExpr = args.get(0);
    if (keyExpr.isParameter()) {
        // Key is a parameter so make sure its type is set
        AbstractMemberMetaData mmd = mapExpr.getJavaTypeMapping().getMemberMetaData();
        if (mmd != null && mmd.getMap() != null) {
            Class keyCls = stmt.getQueryGenerator().getClassLoaderResolver().classForName(mmd.getMap().getKeyType());
            stmt.getQueryGenerator().bindParameter(keyExpr.getParameterName(), keyCls);
        }
    }
    SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
    ClassLoaderResolver clr = stmt.getQueryGenerator().getClassLoaderResolver();
    if (expr instanceof MapLiteral) {
        // Literal Map
        MapLiteral lit = (MapLiteral) expr;
        Map map = (Map) lit.getValue();
        JavaTypeMapping m = exprFactory.getMappingForType(boolean.class, true);
        if (map == null || map.size() == 0) {
            return exprFactory.newLiteral(stmt, m, true).eq(exprFactory.newLiteral(stmt, m, false));
        }
        boolean useInExpression = false;
        List<SQLExpression> mapKeyExprs = lit.getKeyLiteral().getKeyExpressions();
        if (mapKeyExprs != null && !mapKeyExprs.isEmpty()) {
            // Make sure the the map key(s) are compatible with the keyExpr
            boolean incompatible = true;
            Class elemtype = clr.classForName(keyExpr.getJavaTypeMapping().getType());
            Iterator<SQLExpression> mapKeyExprIter = mapKeyExprs.iterator();
            while (mapKeyExprIter.hasNext()) {
                SQLExpression mapKeyExpr = mapKeyExprIter.next();
                Class mapKeyType = clr.classForName(mapKeyExpr.getJavaTypeMapping().getType());
                if (keyTypeCompatible(elemtype, mapKeyType)) {
                    incompatible = false;
                    break;
                }
            }
            if (incompatible) {
                // The provided element type isn't assignable to any of the input collection elements!
                return exprFactory.newLiteral(stmt, m, true).eq(exprFactory.newLiteral(stmt, m, false));
            }
            // Check if we should compare using an "IN (...)" expression
            SQLExpression mapKeyExpr = mapKeyExprs.get(0);
            if (mapKeyExpr instanceof StringExpression || mapKeyExpr instanceof NumericExpression || mapKeyExpr instanceof TemporalExpression || mapKeyExpr instanceof CharacterExpression || mapKeyExpr instanceof EnumExpression) {
                useInExpression = true;
            }
        }
        if (useInExpression) {
            // Return "key IN (val1, val2, ...)"
            SQLExpression[] exprs = (mapKeyExprs != null ? mapKeyExprs.toArray(new SQLExpression[mapKeyExprs.size()]) : null);
            return new InExpression(keyExpr, exprs);
        }
        // TODO If keyExpr is a parameter and mapExpr is derived from a parameter ?
        MapKeyLiteral mapKeyLiteral = lit.getKeyLiteral();
        BooleanExpression bExpr = null;
        List<SQLExpression> elementExprs = mapKeyLiteral.getKeyExpressions();
        for (int i = 0; i < elementExprs.size(); i++) {
            if (bExpr == null) {
                bExpr = (elementExprs.get(i)).eq(keyExpr);
            } else {
                bExpr = bExpr.ior((elementExprs.get(i)).eq(keyExpr));
            }
        }
        if (bExpr != null) {
            bExpr.encloseInParentheses();
        }
        return bExpr;
    }
    if (stmt.getQueryGenerator().getCompilationComponent() == CompilationComponent.FILTER) {
        boolean useSubquery = getNeedsSubquery(stmt);
        JoinType joinType = JoinType.INNER_JOIN;
        if (keyExpr instanceof UnboundExpression) {
            // See if the user has defined what should be used
            String varName = ((UnboundExpression) keyExpr).getVariableName();
            String extensionName = "datanucleus.query.jdoql." + varName + ".join";
            String extensionValue = (String) stmt.getQueryGenerator().getValueForExtension(extensionName);
            if (extensionValue != null) {
                if (extensionValue.equalsIgnoreCase("SUBQUERY")) {
                    useSubquery = true;
                } else if (extensionValue.equalsIgnoreCase("INNERJOIN")) {
                    useSubquery = false;
                } else if (extensionValue.equalsIgnoreCase("LEFTOUTERJOIN")) {
                    joinType = JoinType.LEFT_OUTER_JOIN;
                }
            }
        }
        // TODO Check if *this* "containsKey" is negated, not any of them (and remove above check)
        if (useSubquery) {
            return containsAsSubquery(stmt, mapExpr, keyExpr);
        }
        return containsAsJoin(stmt, mapExpr, keyExpr, joinType);
    }
    return containsAsSubquery(stmt, mapExpr, keyExpr);
}
Also used : SQLExpressionFactory(org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) JavaTypeMapping(org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping) InExpression(org.datanucleus.store.rdbms.sql.expression.InExpression) UnboundExpression(org.datanucleus.store.rdbms.sql.expression.UnboundExpression) BooleanExpression(org.datanucleus.store.rdbms.sql.expression.BooleanExpression) MapExpression(org.datanucleus.store.rdbms.sql.expression.MapExpression) TemporalExpression(org.datanucleus.store.rdbms.sql.expression.TemporalExpression) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) NumericExpression(org.datanucleus.store.rdbms.sql.expression.NumericExpression) JoinType(org.datanucleus.store.rdbms.sql.SQLJoin.JoinType) EnumExpression(org.datanucleus.store.rdbms.sql.expression.EnumExpression) CharacterExpression(org.datanucleus.store.rdbms.sql.expression.CharacterExpression) MapLiteral(org.datanucleus.store.rdbms.sql.expression.MapLiteral) StringExpression(org.datanucleus.store.rdbms.sql.expression.StringExpression) DatastoreClass(org.datanucleus.store.rdbms.table.DatastoreClass) NucleusException(org.datanucleus.exceptions.NucleusException) AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData) Map(java.util.Map) MapKeyLiteral(org.datanucleus.store.rdbms.sql.expression.MapLiteral.MapKeyLiteral)

Example 3 with StringExpression

use of org.datanucleus.store.rdbms.sql.expression.StringExpression in project datanucleus-rdbms by datanucleus.

the class ArrayContainsMethod method getExpression.

/* (non-Javadoc)
     * @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
     */
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
    if (args == null || args.size() != 1) {
        throw new NucleusException("Incorrect arguments for Array.contains(SQLExpression)");
    }
    ClassLoaderResolver clr = stmt.getQueryGenerator().getClassLoaderResolver();
    SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
    ArrayExpression arrExpr = (ArrayExpression) expr;
    SQLExpression elemExpr = args.get(0);
    if (elemExpr.isParameter()) {
        // Element is a parameter so make sure its type is set
        AbstractMemberMetaData mmd = arrExpr.getJavaTypeMapping().getMemberMetaData();
        if (mmd != null) {
            stmt.getQueryGenerator().bindParameter(elemExpr.getParameterName(), mmd.getType().getComponentType());
        }
    }
    if (expr instanceof ArrayLiteral) {
        if (elemExpr instanceof UnboundExpression) {
            Class elemCls = clr.classForName(arrExpr.getJavaTypeMapping().getType()).getComponentType();
            elemExpr = stmt.getQueryGenerator().bindVariable((UnboundExpression) elemExpr, elemCls);
        }
        ArrayLiteral lit = (ArrayLiteral) expr;
        Object array = lit.getValue();
        JavaTypeMapping m = exprFactory.getMappingForType(boolean.class, true);
        if (array == null || Array.getLength(array) == 0) {
            return exprFactory.newLiteral(stmt, m, true).eq(exprFactory.newLiteral(stmt, m, false));
        }
        if (arrExpr.isParameter()) {
            stmt.getQueryGenerator().useParameterExpressionAsLiteral((ArrayLiteral) arrExpr);
        }
        boolean useInExpression = false;
        List<SQLExpression> collElementExprs = lit.getElementExpressions();
        if (collElementExprs != null && !collElementExprs.isEmpty()) {
            // Make sure the the collection element(s) are compatible with the elemExpr
            boolean incompatible = true;
            Class elemtype = clr.classForName(elemExpr.getJavaTypeMapping().getType());
            Iterator<SQLExpression> collElementExprIter = collElementExprs.iterator();
            while (collElementExprIter.hasNext()) {
                SQLExpression collElementExpr = collElementExprIter.next();
                Class collElemType = clr.classForName(collElementExpr.getJavaTypeMapping().getType());
                if (elementTypeCompatible(elemtype, collElemType)) {
                    incompatible = false;
                    break;
                }
            }
            if (incompatible) {
                // The provided element type isn't assignable to any of the input collection elements!
                return exprFactory.newLiteral(stmt, m, true).eq(exprFactory.newLiteral(stmt, m, false));
            }
            // Check if we should compare using an "IN (...)" expression
            SQLExpression collElementExpr = collElementExprs.get(0);
            if (collElementExpr instanceof StringExpression || collElementExpr instanceof NumericExpression || collElementExpr instanceof TemporalExpression || collElementExpr instanceof CharacterExpression || collElementExpr instanceof EnumExpression) {
                useInExpression = true;
            }
        }
        if (useInExpression) {
            // Return "elem IN (val1, val2, ...)"
            SQLExpression[] exprs = (collElementExprs != null ? collElementExprs.toArray(new SQLExpression[collElementExprs.size()]) : null);
            return new InExpression(elemExpr, exprs);
        }
        // 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));
            }
        }
        if (bExpr != null) {
            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));
            }
        }
        if (bExpr != null) {
            bExpr.encloseInParentheses();
        }
        return bExpr;
    } else {
        // TODO Support inner join variant
        return containsAsSubquery(stmt, arrExpr, elemExpr);
    }
}
Also used : TemporalExpression(org.datanucleus.store.rdbms.sql.expression.TemporalExpression) SQLExpressionFactory(org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) JavaTypeMapping(org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping) InExpression(org.datanucleus.store.rdbms.sql.expression.InExpression) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) NumericExpression(org.datanucleus.store.rdbms.sql.expression.NumericExpression) UnboundExpression(org.datanucleus.store.rdbms.sql.expression.UnboundExpression) EnumExpression(org.datanucleus.store.rdbms.sql.expression.EnumExpression) ArrayLiteral(org.datanucleus.store.rdbms.sql.expression.ArrayLiteral) CharacterExpression(org.datanucleus.store.rdbms.sql.expression.CharacterExpression) BooleanExpression(org.datanucleus.store.rdbms.sql.expression.BooleanExpression) StringExpression(org.datanucleus.store.rdbms.sql.expression.StringExpression) ArrayExpression(org.datanucleus.store.rdbms.sql.expression.ArrayExpression) DatastoreClass(org.datanucleus.store.rdbms.table.DatastoreClass) List(java.util.List) NucleusException(org.datanucleus.exceptions.NucleusException) AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData)

Example 4 with StringExpression

use of org.datanucleus.store.rdbms.sql.expression.StringExpression in project datanucleus-rdbms by datanucleus.

the class AvgWithCastFunction method getAggregateExpression.

protected SQLExpression getAggregateExpression(SQLStatement stmt, List args, JavaTypeMapping m) {
    Class argType = ((SQLExpression) args.get(0)).getJavaTypeMapping().getJavaType();
    List<SQLExpression> checkedArgs = null;
    // Only add the CAST if the argument is a non-floating point
    if (!argType.equals(Double.class) && !argType.equals(Float.class)) {
        checkedArgs = new ArrayList<>();
        checkedArgs.add(new StringExpression(stmt, m, "CAST", args, asList("double")));
    } else {
        checkedArgs = args;
    }
    return new AggregateNumericExpression(stmt, m, getFunctionName(), checkedArgs);
}
Also used : SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) AggregateNumericExpression(org.datanucleus.store.rdbms.sql.expression.AggregateNumericExpression) StringExpression(org.datanucleus.store.rdbms.sql.expression.StringExpression)

Example 5 with StringExpression

use of org.datanucleus.store.rdbms.sql.expression.StringExpression in project datanucleus-rdbms by datanucleus.

the class CoalesceFunction method getExpression.

/* (non-Javadoc)
     * @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
     */
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
    if (expr == null) {
        // Find expression type that this handles - all expressions need to be consistent in our implementation
        Class exprType = null;
        Class cls = null;
        int clsLevel = 0;
        for (int i = 0; i < args.size(); i++) {
            SQLExpression argExpr = args.get(i);
            if (exprType == null) {
                if (argExpr instanceof NumericExpression) {
                    exprType = NumericExpression.class;
                    cls = Integer.class;
                } else if (argExpr instanceof StringExpression) {
                    exprType = StringExpression.class;
                    cls = String.class;
                } else if (argExpr instanceof TemporalExpression) {
                    exprType = TemporalExpression.class;
                    cls = argExpr.getJavaTypeMapping().getJavaType();
                } else {
                    exprType = argExpr.getClass();
                    cls = argExpr.getJavaTypeMapping().getJavaType();
                }
            } else {
                if (!exprType.isAssignableFrom(argExpr.getClass())) {
                    throw new NucleusUserException("COALESCE invocation first argument of type " + exprType.getName() + " yet subsequent argument of type " + argExpr.getClass().getName());
                }
            }
            if (exprType == NumericExpression.class) {
                // Priority order is Double, Float, BigDecimal, BigInteger, Long, Integer
                Class argType = argExpr.getJavaTypeMapping().getJavaType();
                if (clsLevel < 5 && (argType == double.class || argType == Double.class)) {
                    cls = Double.class;
                    clsLevel = 5;
                } else if (clsLevel < 4 && (argType == float.class || argType == Float.class)) {
                    cls = Float.class;
                    clsLevel = 4;
                } else if (clsLevel < 3 && argType == BigDecimal.class) {
                    cls = BigDecimal.class;
                    clsLevel = 3;
                } else if (clsLevel < 2 && argType == BigInteger.class) {
                    cls = BigInteger.class;
                    clsLevel = 2;
                } else if (clsLevel < 1 && (argType == long.class || argType == Long.class)) {
                    cls = Long.class;
                    clsLevel = 1;
                }
            }
        }
        SQLExpressionFactory exprFactory = stmt.getSQLExpressionFactory();
        if (exprType == NumericExpression.class) {
            return new NumericExpression(stmt, exprFactory.getMappingForType(cls, true), "COALESCE", args);
        } else if (exprType == StringExpression.class) {
            return new StringExpression(stmt, exprFactory.getMappingForType(cls, true), "COALESCE", args);
        } else if (exprType == TemporalExpression.class) {
            return new TemporalExpression(stmt, exprFactory.getMappingForType(cls, true), "COALESCE", args);
        } else {
            return new ObjectExpression(stmt, exprFactory.getMappingForType(cls, true), "COALESCE", args);
        }
    }
    throw new NucleusException(Localiser.msg("060002", "COALESCE", expr));
}
Also used : TemporalExpression(org.datanucleus.store.rdbms.sql.expression.TemporalExpression) SQLExpressionFactory(org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) NucleusUserException(org.datanucleus.exceptions.NucleusUserException) NumericExpression(org.datanucleus.store.rdbms.sql.expression.NumericExpression) BigDecimal(java.math.BigDecimal) StringExpression(org.datanucleus.store.rdbms.sql.expression.StringExpression) BigInteger(java.math.BigInteger) NucleusException(org.datanucleus.exceptions.NucleusException) ObjectExpression(org.datanucleus.store.rdbms.sql.expression.ObjectExpression)

Aggregations

StringExpression (org.datanucleus.store.rdbms.sql.expression.StringExpression)43 SQLExpression (org.datanucleus.store.rdbms.sql.expression.SQLExpression)33 ArrayList (java.util.ArrayList)29 NucleusException (org.datanucleus.exceptions.NucleusException)28 NumericExpression (org.datanucleus.store.rdbms.sql.expression.NumericExpression)24 JavaTypeMapping (org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping)23 SQLExpressionFactory (org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory)23 CharacterExpression (org.datanucleus.store.rdbms.sql.expression.CharacterExpression)18 ParameterLiteral (org.datanucleus.store.rdbms.sql.expression.ParameterLiteral)16 StringLiteral (org.datanucleus.store.rdbms.sql.expression.StringLiteral)12 BooleanExpression (org.datanucleus.store.rdbms.sql.expression.BooleanExpression)9 RDBMSStoreManager (org.datanucleus.store.rdbms.RDBMSStoreManager)8 TemporalExpression (org.datanucleus.store.rdbms.sql.expression.TemporalExpression)8 List (java.util.List)7 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)5 IntegerLiteral (org.datanucleus.store.rdbms.sql.expression.IntegerLiteral)5 SQLLiteral (org.datanucleus.store.rdbms.sql.expression.SQLLiteral)5 UnboundExpression (org.datanucleus.store.rdbms.sql.expression.UnboundExpression)5 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)4 EnumExpression (org.datanucleus.store.rdbms.sql.expression.EnumExpression)4