Search in sources :

Example 1 with Expression

use of org.datanucleus.query.expression.Expression 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 Expression

use of org.datanucleus.query.expression.Expression in project datanucleus-rdbms by datanucleus.

the class QueryToSQLMapper method compileFrom.

/**
 * Method to compile the FROM clause of the query into the SQLStatement.
 */
protected void compileFrom() {
    if (compilation.getExprFrom() != null) {
        // Process all ClassExpression(s) in the FROM, adding joins to the statement as required
        compileComponent = CompilationComponent.FROM;
        Expression[] fromExprs = compilation.getExprFrom();
        for (Expression fromExpr : fromExprs) {
            compileFromClassExpression((ClassExpression) fromExpr);
        }
        compileComponent = null;
    }
}
Also used : 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)

Example 3 with Expression

use of org.datanucleus.query.expression.Expression in project datanucleus-rdbms by datanucleus.

the class QueryToSQLMapper method getInvokedSqlExpressionForInvokeExpression.

protected SQLExpression getInvokedSqlExpressionForInvokeExpression(InvokeExpression expr) {
    Expression invokedExpr = expr.getLeft();
    SQLExpression invokedSqlExpr = null;
    if (invokedExpr == null) {
    // Static method
    } else if (invokedExpr instanceof PrimaryExpression) {
        processPrimaryExpression((PrimaryExpression) invokedExpr);
        invokedSqlExpr = stack.pop();
    } else if (invokedExpr instanceof Literal) {
        processLiteral((Literal) invokedExpr);
        invokedSqlExpr = stack.pop();
    } else if (invokedExpr instanceof ParameterExpression) {
        // TODO May be needed to set the second parameter to "false" here and then if the method
        // being invoked needs the parameters as a normal SQLLiteral then allow it to convert it itself
        processParameterExpression((ParameterExpression) invokedExpr, true);
        invokedSqlExpr = stack.pop();
    } else if (invokedExpr instanceof InvokeExpression) {
        processInvokeExpression((InvokeExpression) invokedExpr);
        invokedSqlExpr = stack.pop();
    } else if (invokedExpr instanceof VariableExpression) {
        processVariableExpression((VariableExpression) invokedExpr);
        invokedSqlExpr = stack.pop();
    } else if (invokedExpr instanceof ArrayExpression) {
        ArrayExpression arrExpr = (ArrayExpression) invokedExpr;
        SQLExpression[] arrSqlExprs = new SQLExpression[arrExpr.getArraySize()];
        for (int i = 0; i < arrExpr.getArraySize(); i++) {
            Expression arrElemExpr = arrExpr.getElement(i);
            arrElemExpr.evaluate(this);
            arrSqlExprs[i] = stack.pop();
        }
        JavaTypeMapping m = exprFactory.getMappingForType(Object[].class, false);
        invokedSqlExpr = new org.datanucleus.store.rdbms.sql.expression.ArrayExpression(stmt, m, arrSqlExprs);
    } else if (invokedExpr instanceof DyadicExpression) {
        DyadicExpression dyExpr = (DyadicExpression) invokedExpr;
        dyExpr.evaluate(this);
        invokedSqlExpr = stack.pop();
    } else {
        throw new NucleusException("Dont currently support invoke expression " + invokedExpr);
    }
    return invokedSqlExpr;
}
Also used : InvokeExpression(org.datanucleus.query.expression.InvokeExpression) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) PrimaryExpression(org.datanucleus.query.expression.PrimaryExpression) JavaTypeMapping(org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping) VariableExpression(org.datanucleus.query.expression.VariableExpression) DyadicExpression(org.datanucleus.query.expression.DyadicExpression) 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) TemporalLiteral(org.datanucleus.store.rdbms.sql.expression.TemporalLiteral) SQLLiteral(org.datanucleus.store.rdbms.sql.expression.SQLLiteral) ParameterLiteral(org.datanucleus.store.rdbms.sql.expression.ParameterLiteral) BooleanLiteral(org.datanucleus.store.rdbms.sql.expression.BooleanLiteral) IntegerLiteral(org.datanucleus.store.rdbms.sql.expression.IntegerLiteral) Literal(org.datanucleus.query.expression.Literal) NullLiteral(org.datanucleus.store.rdbms.sql.expression.NullLiteral) ParameterExpression(org.datanucleus.query.expression.ParameterExpression) ArrayExpression(org.datanucleus.query.expression.ArrayExpression) NucleusException(org.datanucleus.exceptions.NucleusException)

Example 4 with Expression

use of org.datanucleus.query.expression.Expression in project datanucleus-rdbms by datanucleus.

the class QueryToSQLMapper method compileOrdering.

/**
 * Method to compile the ordering clause of the query into the SQLStatement.
 * @param stmt SELECT statement
 */
protected void compileOrdering(SelectStatement stmt) {
    if (compilation.getExprOrdering() != null) {
        compileComponent = CompilationComponent.ORDERING;
        Expression[] orderingExpr = compilation.getExprOrdering();
        SQLExpression[] orderSqlExprs = new SQLExpression[orderingExpr.length];
        boolean[] directions = new boolean[orderingExpr.length];
        NullOrderingType[] nullOrders = new NullOrderingType[orderingExpr.length];
        for (int i = 0; i < orderingExpr.length; i++) {
            OrderExpression orderExpr = (OrderExpression) orderingExpr[i];
            Expression expr = orderExpr.getLeft();
            if (expr instanceof PrimaryExpression) {
                PrimaryExpression orderPrimExpr = (PrimaryExpression) expr;
                if (orderPrimExpr.getTuples().size() == 1 && resultAliases != null) {
                    if (resultAliases.contains(orderPrimExpr.getId().toLowerCase())) {
                        // Order by a result alias
                        orderSqlExprs[i] = new ResultAliasExpression(stmt, orderPrimExpr.getId());
                    }
                }
            }
            if (orderSqlExprs[i] == null) {
                orderSqlExprs[i] = (SQLExpression) orderExpr.getLeft().evaluate(this);
            }
            String orderDir = orderExpr.getSortOrder();
            directions[i] = ((orderDir == null || orderDir.equals("ascending")) ? false : true);
            nullOrders[i] = orderExpr.getNullOrder();
        }
        stmt.setOrdering(orderSqlExprs, directions, nullOrders);
        compileComponent = null;
    }
}
Also used : NullOrderingType(org.datanucleus.query.NullOrderingType) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) PrimaryExpression(org.datanucleus.query.expression.PrimaryExpression) 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) OrderExpression(org.datanucleus.query.expression.OrderExpression) ResultAliasExpression(org.datanucleus.store.rdbms.sql.expression.ResultAliasExpression)

Example 5 with Expression

use of org.datanucleus.query.expression.Expression in project datanucleus-rdbms by datanucleus.

the class JDOQLQuery method compileQueryUpdate.

/**
 * Method to compile the query for RDBMS for a bulk update.
 * @param parameterValues The parameter values (if any)
 * @param candidateCmd Meta-data for the candidate class
 */
protected void compileQueryUpdate(Map parameterValues, AbstractClassMetaData candidateCmd) {
    Expression[] updateExprs = compilation.getExprUpdate();
    if (updateExprs == null || updateExprs.length == 0) {
        // Nothing to update
        return;
    }
    // Generate statement for candidate
    RDBMSStoreManager storeMgr = (RDBMSStoreManager) getStoreManager();
    DatastoreClass candidateTbl = storeMgr.getDatastoreClass(candidateCmd.getFullClassName(), clr);
    if (candidateTbl == null) {
        throw new NucleusDataStoreException("Bulk update of " + candidateCmd.getFullClassName() + " not supported since candidate has no table of its own");
    }
    List<BulkTable> tables = new ArrayList<>();
    tables.add(new BulkTable(candidateTbl, true));
    if (candidateTbl.getSuperDatastoreClass() != null) {
        DatastoreClass tbl = candidateTbl;
        while (tbl.getSuperDatastoreClass() != null) {
            tbl = tbl.getSuperDatastoreClass();
            tables.add(new BulkTable(tbl, false));
        }
    }
    List<SQLStatement> stmts = new ArrayList<>();
    List<Boolean> stmtCountFlags = new ArrayList<>();
    for (BulkTable bulkTable : tables) {
        // Generate statement for candidate
        DatastoreClass table = bulkTable.table;
        Map<String, Object> extensions = null;
        if (!storeMgr.getDatastoreAdapter().supportsOption(DatastoreAdapter.UPDATE_DELETE_STATEMENT_ALLOW_TABLE_ALIAS_IN_WHERE_CLAUSE)) {
            extensions = new HashMap<>();
            extensions.put(SQLStatement.EXTENSION_SQL_TABLE_NAMING_STRATEGY, "table-name");
        }
        UpdateStatement stmt = new UpdateStatement(storeMgr, table, null, null, extensions);
        stmt.setClassLoaderResolver(clr);
        stmt.setCandidateClassName(candidateCmd.getFullClassName());
        JavaTypeMapping multitenancyMapping = table.getSurrogateMapping(SurrogateColumnType.MULTITENANCY, false);
        if (multitenancyMapping != null) {
            // Multi-tenancy restriction
            SQLExpression tenantExpr = stmt.getSQLExpressionFactory().newExpression(stmt, stmt.getPrimaryTable(), multitenancyMapping);
            SQLExpression tenantVal = stmt.getSQLExpressionFactory().newLiteral(stmt, multitenancyMapping, ec.getNucleusContext().getMultiTenancyId(ec, candidateCmd));
            stmt.whereAnd(tenantExpr.eq(tenantVal), true);
        }
        // TODO Discriminator restriction?
        JavaTypeMapping softDeleteMapping = table.getSurrogateMapping(SurrogateColumnType.SOFTDELETE, false);
        if (softDeleteMapping != null) {
            // Soft-delete restriction
            SQLExpression softDeleteExpr = stmt.getSQLExpressionFactory().newExpression(stmt, stmt.getPrimaryTable(), softDeleteMapping);
            SQLExpression softDeleteVal = stmt.getSQLExpressionFactory().newLiteral(stmt, softDeleteMapping, Boolean.FALSE);
            stmt.whereAnd(softDeleteExpr.eq(softDeleteVal), true);
        }
        Set<String> options = new HashSet<>();
        if (getBooleanExtensionProperty(EXTENSION_USE_IS_NULL_WHEN_EQUALS_NULL_PARAM, true)) {
            options.add(QueryToSQLMapper.OPTION_NULL_PARAM_USE_IS_NULL);
        }
        QueryToSQLMapper sqlMapper = new QueryToSQLMapper(stmt, compilation, parameterValues, null, null, candidateCmd, subclasses, getFetchPlan(), ec, null, options, extensions);
        setMapperJoinTypes(sqlMapper);
        sqlMapper.compile();
        if (stmt.hasUpdates()) {
            stmts.add(stmt);
            stmtCountFlags.add(bulkTable.useInCount);
            datastoreCompilation.setStatementParameters(stmt.getSQLText().getParametersForStatement());
            datastoreCompilation.setPrecompilable(sqlMapper.isPrecompilable());
        }
    }
    datastoreCompilation.clearStatements();
    Iterator<SQLStatement> stmtIter = stmts.iterator();
    Iterator<Boolean> stmtCountFlagsIter = stmtCountFlags.iterator();
    while (stmtIter.hasNext()) {
        SQLStatement stmt = stmtIter.next();
        Boolean useInCount = stmtCountFlagsIter.next();
        if (stmts.size() == 1) {
            useInCount = true;
        }
        datastoreCompilation.addStatement(stmt, stmt.getSQLText().toSQL(), useInCount);
    }
}
Also used : UpdateStatement(org.datanucleus.store.rdbms.sql.UpdateStatement) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) JavaTypeMapping(org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping) ArrayList(java.util.ArrayList) SQLStatement(org.datanucleus.store.rdbms.sql.SQLStatement) RDBMSStoreManager(org.datanucleus.store.rdbms.RDBMSStoreManager) NucleusDataStoreException(org.datanucleus.exceptions.NucleusDataStoreException) Expression(org.datanucleus.query.expression.Expression) BooleanExpression(org.datanucleus.store.rdbms.sql.expression.BooleanExpression) SQLExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression) DatastoreClass(org.datanucleus.store.rdbms.table.DatastoreClass) HashSet(java.util.HashSet)

Aggregations

Expression (org.datanucleus.query.expression.Expression)93 InvokeExpression (org.datanucleus.query.expression.InvokeExpression)81 PrimaryExpression (org.datanucleus.query.expression.PrimaryExpression)66 DyadicExpression (org.datanucleus.query.expression.DyadicExpression)65 ParameterExpression (org.datanucleus.query.expression.ParameterExpression)65 VariableExpression (org.datanucleus.query.expression.VariableExpression)57 NucleusException (org.datanucleus.exceptions.NucleusException)41 Literal (org.datanucleus.query.expression.Literal)37 OrderExpression (org.datanucleus.query.expression.OrderExpression)31 QueryCompilation (org.datanucleus.query.compiler.QueryCompilation)28 JavaQueryCompiler (org.datanucleus.query.compiler.JavaQueryCompiler)25 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)24 CreatorExpression (org.datanucleus.query.expression.CreatorExpression)23 ClassExpression (org.datanucleus.query.expression.ClassExpression)22 JoinExpression (org.datanucleus.query.expression.JoinExpression)22 SubqueryExpression (org.datanucleus.query.expression.SubqueryExpression)22 HashMap (java.util.HashMap)17 ArrayExpression (org.datanucleus.query.expression.ArrayExpression)17 CaseExpression (org.datanucleus.query.expression.CaseExpression)17 JDOQLCompiler (org.datanucleus.query.compiler.JDOQLCompiler)16