code: public DCollection query(String predicate) throws QueryInvalidException
      {
          // 1.build complete OQL statement
          String oql = "select all from java.lang.Object where " + predicate;
          TransactionImpl tx = getTransaction();
          if (tx == null) throw new QueryInvalidException("Need running transaction to do query");
  
          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;
  
      }
docs: Evaluate the boolean query predicate for each element of the collection and
  return a new collection that contains each element that evaluated to true.
  @param	predicate	An OQL boolean query predicate.
  @return	A new collection containing the elements that evaluated true for the predicate.
  @exception	org.odmg.QueryInvalidException	The query predicate is invalid.