" WHERE " + (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") + "parent_id IN " + DbUtil.suitableNumberOfVariables(count) +
" WHERE " + IN_THIS_MAILBOX_AND + "parent_id IN " + DbUtil.suitableNumberOfVariables(count) +
    private static void completeConversations(Mailbox mbox, List<UnderlyingData> convData) throws ServiceException {        if (convData == null || convData.isEmpty())            return;        Map<Integer, UnderlyingData> conversations = new HashMap<Integer, UnderlyingData>();        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        ResultSet rs = null;                for (int i = 0; i < convData.size(); i += DbUtil.IN_CLAUSE_BATCH_SIZE)            try {                int count = Math.min(DbUtil.IN_CLAUSE_BATCH_SIZE, convData.size() - i);                String sql = "SELECT parent_id, id, unread, flags, tags" +                             " FROM " + getMailItemTableName(mbox.getId()) +                             " WHERE " +                             (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") +                             "parent_id IN " + DbUtil.suitableNumberOfVariables(count) +                             " ORDER BY parent_id";                stmt = conn.prepareStatement(sql);                int pos = 1;                if (DebugConfig.enableMailboxGroup)                    stmt.setInt(pos++, mbox.getId());                for (int index = i; index < i + count; index++) {                    UnderlyingData data = convData.get(index);                    assert(data.type == MailItem.TYPE_CONVERSATION);                    stmt.setInt(pos++, data.id);                    conversations.put(data.id, data);                }                rs = stmt.executeQuery();                int lastConvId = -1;                List<Long> inheritedTags = new ArrayList<Long>();                List<Integer> children = new ArrayList<Integer>();                int unreadCount = 0;                                while (rs.next()) {                    int convId = rs.getInt(1);                    if (convId != lastConvId) {                        // New conversation.  Update stats for the last one and reset counters.                        if (lastConvId != -1) {                            // Update stats for the previous conversation                            UnderlyingData data = conversations.get(lastConvId);                            data.children      = children;                            data.unreadCount   = unreadCount;                            data.inheritedTags = StringUtil.join(",", inheritedTags);                        }                        lastConvId = convId;                        children = new ArrayList<Integer>();                        inheritedTags.clear();                        unreadCount = 0;                    }                                        // Read next row                    children.add(rs.getInt(2));                    if (rs.getBoolean(3))                        unreadCount++;                    inheritedTags.add(-rs.getLong(4));                    inheritedTags.add(rs.getLong(5));                }                                // Update the last conversation.                UnderlyingData data = conversations.get(lastConvId);                if (data != null) {                    data.children      = children;                    data.unreadCount   = unreadCount;                    data.inheritedTags = StringUtil.join(",", inheritedTags);                } else {                    // Data error: no messages found                    StringBuilder msg = new StringBuilder("No messages found for conversations:");                    for (UnderlyingData ud : convData) {                        msg.append(' ').append(ud.id);                    }                    msg.append(".  lastConvId=").append(lastConvId);                    sLog.error(msg);                }            } catch (SQLException e) {                throw ServiceException.FAILURE("completing conversation data", e);            } finally {                DbPool.closeResults(rs);                DbPool.closeStatement(stmt);            }    }