Examples of JDOQLEvaluator


Examples of org.datanucleus.query.evaluator.JDOQLEvaluator

                return Collections.EMPTY_LIST;
            }
            else if (inMemory)
            {
                List candidates = new ArrayList(candidateCollection);
                JavaQueryEvaluator resultMapper = new JDOQLEvaluator(this, candidates, compilation,
                    parameters, clr);
                return resultMapper.execute(true, true, true, true, true);
            }
        }
        else if (type == Query.SELECT)
        {
            // Query results are cached, so return those
            List<Object> cachedResults = getQueryManager().getDatastoreQueryResult(this, parameters);
            if (cachedResults != null)
            {
                return new CandidateIdsQueryResult(this, cachedResults);
            }
        }

        Object results = null;
        ManagedConnection mconn = ec.getStoreManager().getConnection(ec);
        try
        {
            // Execute the query
            long startTime = System.currentTimeMillis();
            if (NucleusLogger.QUERY.isDebugEnabled())
            {
                NucleusLogger.QUERY.debug(LOCALISER.msg("021046", getLanguage(), getSingleStringQuery(),
                    null));
            }

            RDBMSStoreManager storeMgr = (RDBMSStoreManager)getStoreManager();
            AbstractClassMetaData acmd = ec.getMetaDataManager().getMetaDataForClass(candidateClass, clr);
            SQLController sqlControl = storeMgr.getSQLController();
            PreparedStatement ps = null;
            try
            {
                if (type == Query.SELECT)
                {
                    // Create PreparedStatement and apply parameters, result settings etc
                    ps = RDBMSQueryUtils.getPreparedStatementForQuery(mconn,
                        datastoreCompilation.getSQL(), this);
                    SQLStatementHelper.applyParametersToStatement(ps, ec,
                        datastoreCompilation.getStatementParameters(),
                        datastoreCompilation.getParameterNameByPosition(), parameters);
                    RDBMSQueryUtils.prepareStatementForExecution(ps, this, true);

                    registerTask(ps);
                    ResultSet rs = null;
                    try
                    {
                        rs = sqlControl.executeStatementQuery(mconn, toString(), ps);
                    }
                    finally
                    {
                        deregisterTask();
                    }

                    QueryResult qr = null;
                    try
                    {
                        if (inMemory)
                        {
                            // IN-MEMORY EVALUATION
                            ResultObjectFactory rof = storeMgr.newResultObjectFactory(acmd,
                                datastoreCompilation.getResultDefinitionForClass(),
                                RDBMSQueryUtils.useUpdateLockForQuery(this), getFetchPlan(),
                                candidateClass);

                            // Just instantiate the candidates for later in-memory processing
                            // TODO Use a queryResult rather than an ArrayList so we load when required
                            List candidates = new ArrayList();
                            while (rs.next())
                            {
                                candidates.add(rof.getObject(ec, rs));
                            }

                            // Perform in-memory filter/result/order etc
                            JavaQueryEvaluator resultMapper =
                                new JDOQLEvaluator(this, candidates, compilation, parameters, clr);
                            results = resultMapper.execute(true, true, true, true, true);
                        }
                        else
                        {
                            // IN-DATASTORE EVALUATION
                            ResultObjectFactory rof = null;
View Full Code Here

Examples of org.datanucleus.query.evaluator.JDOQLEvaluator

                candidates = new XMLCandidateList(candidateClass, subclasses, ec, 
                    (String)getExtension(Query.EXTENSION_RESULT_CACHE_TYPE), mconn, ignoreCache);
            }

            // Apply any result restrictions to the XML XPath results
            JavaQueryEvaluator resultMapper = new JDOQLEvaluator(this, candidates, compilation,
                parameters, ec.getClassLoaderResolver());
            Collection results = resultMapper.execute(true, true, true, true, true);

            if (NucleusLogger.QUERY.isDebugEnabled())
            {
                NucleusLogger.QUERY.debug(LOCALISER.msg("021074", "JDOQL",
                    "" + (System.currentTimeMillis() - startTime)));
View Full Code Here

Examples of org.datanucleus.query.evaluator.JDOQLEvaluator

            candidates.add(iter.next());
          }
        }

        // Evaluate in-memory over the candidate instances
        JavaQueryEvaluator resultMapper = new JDOQLEvaluator(this, candidates, compilation,
            parameters, ec.getClassLoaderResolver());
        results = resultMapper.execute(true, true, true, true, true);
    }
    else {
      // Evaluate in-datastore
      boolean inmemoryWhenUnsupported = getEvaluateInMemoryWhenUnsupported();
      QueryData qd = datastoreQuery.compile(compilation, parameters, inmemoryWhenUnsupported);
      if (NucleusLogger.QUERY.isDebugEnabled()) {
        // Log the query
        NucleusLogger.QUERY.debug("Query compiled as : " + qd.getDatastoreQueryAsString());
      }

      results = datastoreQuery.performExecute(qd);

      boolean filterInMemory = false;
      boolean orderInMemory = false;
      boolean resultInMemory = (result != null || grouping != null || having != null || resultClass != null);
      if (inmemoryWhenUnsupported) {
        // Set filter/order flags according to what the query can manage in-datastore
        filterInMemory = !datastoreQuery.isFilterComplete();

        if (ordering != null) {
          if (filterInMemory) {
            orderInMemory = true;
          } else {
            if (!datastoreQuery.isOrderComplete()) {
              orderInMemory = true;
            }
          }
        }
      }

      // Evaluate any remaining parts in-memory
      if (filterInMemory || resultInMemory || orderInMemory) {
        JavaQueryEvaluator resultMapper = new JDOQLEvaluator(this, (List)results, compilation,
            parameters, ec.getClassLoaderResolver());
        results = resultMapper.execute(filterInMemory, orderInMemory,
            resultInMemory, resultClass != null, false);
      }

      if (results instanceof AbstractQueryResult) {
        // Lazy loading results : add listener to the connection so we can get a callback when the connection is flushed.
View Full Code Here

Examples of org.datanucleus.query.evaluator.JDOQLEvaluator

                candidates = MongoDBUtils.getObjectsOfCandidateType(ec, db, candidateClass, subclasses,
                    ignoreCache, getFetchPlan(), filterObject, options);
            }

            // Apply any result restrictions to the results
            JavaQueryEvaluator resultMapper = new JDOQLEvaluator(this, candidates, compilation,
                parameters, ec.getClassLoaderResolver());
            Collection results = resultMapper.execute(true, true, true, true, true);

            if (NucleusLogger.QUERY.isDebugEnabled())
            {
                NucleusLogger.QUERY.debug(LOCALISER.msg("021074", "JDOQL",
                    "" + (System.currentTimeMillis() - startTime)));
View Full Code Here

Examples of org.datanucleus.query.evaluator.JDOQLEvaluator

                List<Object> rawResults =
                    new ForceQueryUtils(ec, mconn, this, parameters, listeners, getExtensions())
                            .getObjectsOfCandidateType(compilation.getExprResult());
                if (ForceQueryUtils.getLimitType(this) == LimitType.Java) {
                    // Apply any result restrictions to the results
                    JavaQueryEvaluator resultMapper = new JDOQLEvaluator(this, rawResults, compilation,
                        parameters, ec.getClassLoaderResolver());
                    results = resultMapper.execute(false, false, false, false, true);
                } else {
                    results = rawResults;
                }
            }

            if (candidates != null) {
                // Apply any result restrictions to the results
                JavaQueryEvaluator resultMapper = new JDOQLEvaluator(this, candidates, compilation,
                    parameters, ec.getClassLoaderResolver());
                results = resultMapper.execute(true, true, true, true, true);
            }

            if (NucleusLogger.QUERY.isDebugEnabled()) {
                NucleusLogger.QUERY.debug(LOCALISER.msg("021074", "JDOQL",
                    "" + (System.currentTimeMillis() - startTime)));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.