public static List  getByParent(MailItem parent, byte sort) throws ServiceException { Mailbox mbox = parent.getMailbox(); Connection conn = mbox.getOperationConnection(); ArrayList result = new ArrayList(); PreparedStatement stmt = null; ResultSet rs = null; try { stmt = conn.prepareStatement("SELECT " + DB_FIELDS + " FROM " + getMailItemTableName(parent.getMailboxId(), " mi") + " WHERE parent_id = ? " + sortQuery(sort)); stmt.setInt(1, parent.getId()); rs = stmt.executeQuery();  while (rs.next()) { UnderlyingData data = constructItem(rs); if (Mailbox.isCachedType(data.type)) throw ServiceException.INVALID_REQUEST("folders and tags must be retrieved from cache", null); result.add(data); } return result; } catch (SQLException e) { throw ServiceException.FAILURE("fetching children of item " + parent.getId(), e); } finally { DbPool.closeResults(rs); DbPool.closeStatement(stmt); }
public static List  getByParent(MailItem parent) throws ServiceException { return getByParent(parent, DEFAULT_SORT_ORDER);
    public static List /*<UnderlyingData>*/ getByParent(MailItem parent, byte sort) throws ServiceException {        Mailbox mbox = parent.getMailbox();        Connection conn = mbox.getOperationConnection();        ArrayList result = new ArrayList();        PreparedStatement stmt = null;        ResultSet rs = null;        try {            stmt = conn.prepareStatement("SELECT " + DB_FIELDS +                    " FROM " + getMailItemTableName(parent.getMailboxId(), " mi") +                    " WHERE parent_id = ? " + sortQuery(sort));            stmt.setInt(1, parent.getId());            rs = stmt.executeQuery();            while (rs.next()) {                UnderlyingData data = constructItem(rs);                if (Mailbox.isCachedType(data.type))                    throw ServiceException.INVALID_REQUEST("folders and tags must be retrieved from cache", null);                result.add(data);            }            return result;        } catch (SQLException e) {        	throw ServiceException.FAILURE("fetching children of item " + parent.getId(), e);        } finally {        	DbPool.closeResults(rs);            DbPool.closeStatement(stmt);        }    }