public PlasmaDataGraph[] find(Query query, int requestMax, Timestamp snapshotDate) {
    Connection con = null;
    try {
      con = JDBCConnectionManager.instance().getConnection();
    } catch (SQLException e2) {
      throw new DataAccessException(e2);
    }
    From from = query.getFromClause();
    PlasmaType type =
        (PlasmaType)
            PlasmaTypeHelper.INSTANCE.getType(
                from.getEntity().getNamespaceURI(), from.getEntity().getName());

    PropertySelectionCollector collector =
        new PropertySelectionCollector(query.getSelectClause(), type);
    collector.setOnlySingularProperties(false);
    collector.setOnlyDeclaredProperties(false); // collect from superclasses
    List<List<PropertyPair>> queryResults = findResults(query, collector, type, con);

    JDBCDataGraphAssembler assembler =
        new JDBCDataGraphAssembler(type, collector, snapshotDate, con);

    if (log.isDebugEnabled()) {
      log.debug("assembling results");
    }

    PlasmaDataGraph[] results = null;
    try {
      if (!query.getSelectClause().hasDistinctProperties())
        results = assembleResults(queryResults, requestMax, assembler);
      else
        results = trimResults(queryResults, requestMax, assembler, query.getSelectClause(), type);
    } finally {
      try {
        con.close();
      } catch (SQLException e) {
        log.error(e.getMessage(), e);
      }
    }

    return results;
  }
 /**
  * Returns a count of the given query. This does NOT return any results but causes a "count(*)" to
  * be issued.
  *
  * @param query the Query Object Model (QOM) query
  * @return the query results size
  */
 public int count(Query query) {
   Connection con = null;
   try {
     con = JDBCConnectionManager.instance().getConnection();
   } catch (SQLException e2) {
     throw new DataAccessException(e2);
   }
   From from = query.getFromClause();
   PlasmaType type =
       (PlasmaType)
           PlasmaTypeHelper.INSTANCE.getType(
               from.getEntity().getNamespaceURI(), from.getEntity().getName());
   int size = this.countResults(con, query, type);
   try {
     con.close();
   } catch (SQLException e) {
     log.error(e.getMessage(), e);
   }
   return size;
 }