public Collection ejbFindByComplex(Integer complexID) throws FinderException {
   Table category = new Table(this, "c");
   Table type = new Table(ApartmentType.class, "t");
   Table apartment = new Table(Apartment.class, "a");
   Table floor = new Table(Floor.class, "f");
   Table building = new Table(Building.class, "b");
   SelectQuery query = new SelectQuery(category);
   query.setAsDistinct(true);
   query.addColumn(new WildCardColumn(category));
   try {
     query.addJoin(type, category);
     query.addJoin(apartment, type);
     query.addJoin(apartment, floor);
     query.addJoin(floor, building);
   } catch (IDORelationshipException e) {
     throw new FinderException(e.getMessage());
   }
   query.addCriteria(
       new MatchCriteria(
           new Column(building, BuildingBMPBean.BU_COMPLEX_ID),
           MatchCriteria.EQUALS,
           complexID.intValue()));
   query.addOrder(category, this.getIDColumnName(), true);
   return idoFindPKsBySQL(query.toString());
 }
  Collection<Object> ejbFindAllCommentsByHolder(String commentHolder) throws FinderException {
    Table table = new Table(this);
    SelectQuery query = new SelectQuery(table);
    query.addColumn(new Column(table, getIDColumnName()));

    query.addCriteria(
        new MatchCriteria(
            new Column(table, COLUMN_COMMENT_HOLDER), MatchCriteria.EQUALS, commentHolder));
    addNotDeletedCriteria(query, table);

    return this.idoFindPKsByQuery(query);
  }
 private void addNotDeletedCriteria(SelectQuery query, Table table) {
   Criteria isNull =
       new MatchCriteria(new Column(table, COLUMN_DELETED), MatchCriteria.IS, MatchCriteria.NULL);
   Criteria isFalse =
       new MatchCriteria(new Column(table, COLUMN_DELETED), MatchCriteria.EQUALS, false);
   query.addCriteria(new OR(isNull, isFalse));
 }