Examples of JPQLEvaluator


Examples of org.datanucleus.query.evaluator.JPQLEvaluator

                return Collections.EMPTY_LIST;
            }
            else
            {
                List candidates = new ArrayList(candidateCollection);
                JavaQueryEvaluator resultMapper = new JPQLEvaluator(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(),
                        null, parameters);
                    RDBMSQueryUtils.prepareStatementForExecution(ps, this, false);

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

                    QueryResult qr = null;
                    try
                    {
                        if (evaluateInMemory())
                        {
                            // 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 JPQLEvaluator(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.JPQLEvaluator

            {
                candidates = new ArrayList(candidateCollection);
            }

            // Apply any result restrictions to the XML XPath results
            JavaQueryEvaluator resultMapper = new JPQLEvaluator(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", "JPQL",
                    "" + (System.currentTimeMillis() - startTime)));
View Full Code Here

Examples of org.datanucleus.query.evaluator.JPQLEvaluator

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

      // Evaluate in-memory over the candidate instances
      JavaQueryEvaluator resultMapper = new JPQLEvaluator(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 JPQLEvaluator(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.JPQLEvaluator

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

            // Apply any result restrictions to the results
            JavaQueryEvaluator resultMapper = new JPQLEvaluator(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", "JPQL",
                    "" + (System.currentTimeMillis() - startTime)));
View Full Code Here

Examples of org.datanucleus.query.evaluator.JPQLEvaluator

            Object results = null;
            if (candidateCollection == null) {
                List<Object> rawResults =
                    new ForceQueryUtils(ec, mconn, this, parameters, null, null).getObjectsOfCandidateType(null);
                if (ForceQueryUtils.getLimitType(this) == LimitType.Java) {
                    JavaQueryEvaluator resultMapper = new JPQLEvaluator(this, rawResults, newDummyQueryCompilation(),
                            parameters, ec.getClassLoaderResolver());
                        results = resultMapper.execute(false, false, false, false, true);
                } else {
                    results = rawResults;
                }
            } else {
                List candidates = new ArrayList(candidateCollection);
                // Apply any result restrictions to the results
                JavaQueryEvaluator resultMapper = new JPQLEvaluator(this, candidates, newDummyQueryCompilation(),
                    parameters, ec.getClassLoaderResolver());
                results = resultMapper.execute(true, true, true, true, true);
            }
   
            if (NucleusLogger.QUERY.isDebugEnabled()) {
                NucleusLogger.QUERY.debug(LOCALISER.msg("021074", "SOQL", "" + (System.currentTimeMillis() - startTime)));
            }
View Full Code Here

Examples of org.datanucleus.query.evaluator.JPQLEvaluator

                if (candidateCollection == null) {
                    List<Object> rawResults =
                        new ForceQueryUtils(ec, mconn, this, parameters, listeners, getExtensions())
                                .getObjectsOfCandidateType(compilation.getExprResult());
                    if (ForceQueryUtils.getLimitType(this) == LimitType.Java) {
                        JavaQueryEvaluator resultMapper = new JPQLEvaluator(this, rawResults, compilation,
                                parameters, ec.getClassLoaderResolver());
                            results = resultMapper.execute(false, false, false, false, true);
                    } else {
                        results = rawResults;
                    }
                } else {
                    List candidates = new ArrayList(candidateCollection);
                    // Apply any result restrictions to the results
                    JavaQueryEvaluator resultMapper = new JPQLEvaluator(this, candidates, compilation,
                        parameters, ec.getClassLoaderResolver());
                    results = resultMapper.execute(true, true, true, true, true);
                }
            }
   
            if (NucleusLogger.QUERY.isDebugEnabled()) {
                NucleusLogger.QUERY.debug(LOCALISER.msg("021074", "JPQL", "" + (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.