/**
* Executes the JDOQL query against the Force.com database.
*/
@Override
protected Object performExecute(Map parameters) {
ForceManagedConnection mconn = (ForceManagedConnection) ec.getStoreManager().getConnection(ec);
try {
long startTime = System.currentTimeMillis();
if (NucleusLogger.QUERY.isDebugEnabled()) {
NucleusLogger.QUERY.debug(LOCALISER.msg("021046", "JDOQL", getSingleStringQuery(), null));
}
Collection results = null;
List candidates = null;
if (candidateCollection != null) {
candidates = new ArrayList(candidateCollection);
} else if (candidateExtent != null) {
candidates = new ArrayList();
Iterator iter = candidateExtent.iterator();
while (iter.hasNext()) {
candidates.add(iter.next());
}
} else {
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)));
}
return results;
} catch (NucleusException ne) {
throw ne;
} catch (Exception e) {
throw new NucleusException(e.getMessage(), e);
} finally {
mconn.release();
}
}