OQLQuery predicateQuery = tx.getImplementation().newOQLQuery();
predicateQuery.create(oql);
Query pQ = ((OQLQueryImpl) predicateQuery).getQuery();
Criteria pCrit = pQ.getCriteria();
PBCapsule handle = new PBCapsule(pbKey, tx);
DList result;
try
{
PersistenceBroker broker = handle.getBroker();
Criteria allElementsCriteria = this.getPkCriteriaForAllElements(broker);
// join selection of elements with predicate criteria:
allElementsCriteria.addAndCriteria(pCrit);
Class clazz = null;
try
{
clazz = this.getElementsExtentClass(broker);
}
catch (PersistenceBrokerException e)
{
getLog().error(e);
throw new ODMGRuntimeException(e.getMessage());
}
Query q = new QueryByCriteria(clazz, allElementsCriteria);
if (getLog().isDebugEnabled()) getLog().debug(q.toString());
result = null;
try
{
result = (DList) broker.getCollectionByQuery(DListImpl.class, q);
}
catch (PersistenceBrokerException e)
{
getLog().error("Query failed", e);
throw new OJBRuntimeException(e);
}
}
finally
{
// cleanup stuff
if (handle != null) handle.destroy();
}
// 3. return resulting collection
return result;