Package org.datanucleus.query.compiler

Examples of org.datanucleus.query.compiler.QueryCompilation


            {
                internalQuery.setCandidates(candidates);
            }
        }

        QueryCompilation compilation = getCompilation();
        internalQuery.setCompilation(compilation);

        return internalQuery;
    }
View Full Code Here


     * Method to compile the typesafe query.
     * @return The generic compilation
     */
    public QueryCompilation compile(MetaDataManager mmgr, ClassLoaderResolver clr)
    {
        QueryCompilation compilation = super.compile(mmgr, clr);

        // Add compilation of any subqueries
        if (subqueries != null && !subqueries.isEmpty())
        {
            Iterator<JDOTypesafeSubquery> iter = subqueries.iterator();
            int i = 0;
            while (iter.hasNext())
            {
                JDOTypesafeSubquery subquery = iter.next();
                QueryCompilation subqueryCompilation = subquery.getCompilation();
                compilation.addSubqueryCompilation(subquery.getAlias(), subqueryCompilation);
                i++;
            }
        }

View Full Code Here

                updateExprs[i++] = new DyadicExpression(updateExpr.getQueryExpression(), Expression.OP_EQ,
                    updateVal.getQueryExpression());
            }
        }

        compilation = new QueryCompilation(candidateCls, candidateAlias, symtbl, resultExprs,
            null, filterExpr, groupingExprs, havingExpr, orderExprs, updateExprs);
        compilation.setQueryLanguage("JDOQL");

        return compilation;
    }
View Full Code Here

            mconn.release();
        }
    }

    private QueryCompilation newDummyQueryCompilation() {
        return new QueryCompilation(getCandidateClass(), null, null, null, null, null, null, null, null, null);
    }
View Full Code Here

                VariableExpression varExpr = (VariableExpression) expr;
                if (varExpr.getSymbol() != null && varExpr.getSymbol().getQualifiedName() != null) {
                    /**
                     * This is vanilla subquery processing, i.e. select ... (select ...) created from JPQL/JDOQL
                     */
                    QueryCompilation subCompilation =
                        h.compilation.getCompilationForSubquery(varExpr.getSymbol().getQualifiedName());
                    if (subCompilation != null) {
                        AbstractClassMetaData cmd =
                            executionContext.getMetaDataManager().getMetaDataForClass(subCompilation.getCandidateClass(),
                                                                            executionContext.getClassLoaderResolver());
                        TableImpl joinTable = ((ForceStoreManager) executionContext.getStoreManager()).getTable(cmd);
                        // Pretend it's a top level query since it has its own compilation. Also fieldsList is null as
                        // we want select to use subCompilation.getExprResult()
                        h.sb.append("(").append(buildQuery(joinTable, cmd, null, subCompilation, true,
View Full Code Here

        {
            for (int i=0;i<subqueryAliases.length;i++)
            {
                // Evaluate subquery first
                Query subquery = query.getSubqueryForVariable(subqueryAliases[i]).getQuery();
                QueryCompilation subqueryCompilation =
                    compilation.getCompilationForSubquery(subqueryAliases[i]);
                Collection subqueryResult = evaluateSubquery(subquery, executeCandidates, subqueryCompilation);

                if (QueryUtils.queryReturnsSingleRow(subquery))
                {
View Full Code Here

        QueryManager queryMgr = om.getOMFContext().getQueryManager();
        boolean caching = getBooleanExtensionProperty("datanucleus.query.cached", true);
        if (caching)
        {
            QueryCompilation cachedCompilation = queryMgr.getQueryCompilationForQuery("JDOQL", toString());
            if (cachedCompilation != null)
            {
                if (NucleusLogger.QUERY.isDebugEnabled())
                {
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021079", toString(), "JDOQL"));
                }
                compilation = cachedCompilation;
                checkParameterTypesAgainstCompilation(parameterValues);
                return;
            }
        }

        long startTime = 0;
        if (NucleusLogger.QUERY.isDebugEnabled())
        {
            startTime = System.currentTimeMillis();
            NucleusLogger.QUERY.debug(LOCALISER.msg("021044", "JDOQL", getSingleStringQuery()));
        }
        JavaQueryCompiler compiler = new JDOQLCompiler(om.getMetaDataManager(), om.getClassLoaderResolver(),
            null, candidateClass, candidateCollection,
            this.filter, getParsedImports(), this.ordering, this.result, this.grouping, this.having,
            explicitParameters, explicitVariables);
        compilation = compiler.compile(parameterValues, subqueries);
        if (QueryUtils.queryReturnsSingleRow(this))
        {
            compilation.setReturnsSingleRow();
        }
        if (NucleusLogger.QUERY.isDebugEnabled())
        {
            NucleusLogger.QUERY.debug(LOCALISER.msg("021045", "JDOQL",
                "" + (System.currentTimeMillis() - startTime)));
        }

        if (subqueries != null)
        {
            // Compile any subqueries
            Iterator iter = subqueries.entrySet().iterator();
            while (iter.hasNext())
            {
                Map.Entry entry = (Map.Entry)iter.next();
                SubqueryDefinition subqueryDefinition = (SubqueryDefinition)entry.getValue();
                Query subquery = subqueryDefinition.getQuery();
                if (NucleusLogger.QUERY.isDebugEnabled())
                {
                    startTime = System.currentTimeMillis();
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021044", "JDOQL",
                        ((AbstractJDOQLQuery)subquery).getSingleStringQuery()));
                }
                compiler = new JDOQLCompiler(om.getMetaDataManager(), om.getClassLoaderResolver(),
                    null, subquery.candidateClass, null,
                    subquery.filter, getParsedImports(), subquery.ordering, subquery.result,
                    subquery.grouping, subquery.having, null, null);
                QueryCompilation subqueryCompilation = compiler.compile(parameterValues, null);
                if (QueryUtils.queryReturnsSingleRow(subquery))
                {
                    subqueryCompilation.setReturnsSingleRow();
                }
                compilation.addSubqueryCompilation((String)entry.getKey(), subqueryCompilation);
                if (NucleusLogger.QUERY.isDebugEnabled())
                {
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021045", "JDOQL",
View Full Code Here

        QueryManager queryMgr = om.getOMFContext().getQueryManager();
        boolean caching = getBooleanExtensionProperty("datanucleus.query.cached", true);
        if (caching)
        {
            QueryCompilation cachedCompilation = queryMgr.getQueryCompilationForQuery("JPQL", toString());
            if (cachedCompilation != null)
            {
                if (NucleusLogger.QUERY.isDebugEnabled())
                {
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021079", toString(), "JPQL"));
                }
                compilation = cachedCompilation;
                if (compilation.getExprResult() == null)
                {
                    // If the result was "Object(e)" or "e" then this is meaningless so remove
                    result = null;
                }
                checkParameterTypesAgainstCompilation(parameterValues);
                return;
            }
        }

        long startTime = 0;
        if (NucleusLogger.QUERY.isDebugEnabled())
        {
            startTime = System.currentTimeMillis();
            NucleusLogger.QUERY.debug(LOCALISER.msg("021044", "JPQL", getSingleStringQuery()));
        }
        JavaQueryCompiler compiler = new JPQLCompiler(om.getMetaDataManager(), om.getClassLoaderResolver(),
            from, candidateClass, candidateCollection,
            this.filter, getParsedImports(), this.ordering, this.result, this.grouping, this.having,
            explicitParameters, update);
        compilation = compiler.compile(parameterValues, subqueries);
        if (QueryUtils.queryReturnsSingleRow(this))
        {
            compilation.setReturnsSingleRow();
        }
        if (compilation.getExprResult() == null)
        {
            // If the result was "Object(e)" or "e" then this is meaningless so remove
            result = null;
        }
        if (NucleusLogger.QUERY.isDebugEnabled())
        {
            NucleusLogger.QUERY.debug(LOCALISER.msg("021045", "JPQL",
                "" + (System.currentTimeMillis() - startTime)));
        }

        if (subqueries != null)
        {
            // Compile any subqueries
            Iterator iter = subqueries.entrySet().iterator();
            while (iter.hasNext())
            {
                Map.Entry entry = (Map.Entry)iter.next();
                SubqueryDefinition subqueryDefinition = (SubqueryDefinition)entry.getValue();
                Query subquery = subqueryDefinition.getQuery();
                if (NucleusLogger.QUERY.isDebugEnabled())
                {
                    startTime = System.currentTimeMillis();
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021044", "JPQL",
                        ((AbstractJPQLQuery)subquery).getSingleStringQuery()));
                }
                compiler = new JPQLCompiler(om.getMetaDataManager(), om.getClassLoaderResolver(),
                    subquery.from, subquery.candidateClass, null,
                    subquery.filter, getParsedImports(), subquery.ordering, subquery.result,
                    subquery.grouping, subquery.having, null, null);
                QueryCompilation subqueryCompilation = compiler.compile(parameterValues, null);
                compilation.addSubqueryCompilation((String)entry.getKey(), subqueryCompilation);
                if (NucleusLogger.QUERY.isDebugEnabled())
                {
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021045", "JPQL",
                        "" + (System.currentTimeMillis() - startTime)));
View Full Code Here

TOP

Related Classes of org.datanucleus.query.compiler.QueryCompilation

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.