" WHERE " + (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") + "unread = ? AND " + relation + " AND type = " + MailItem.TYPE_MESSAGE);
" WHERE " + IN_THIS_MAILBOX_AND + "unread = ? AND " + relation + " AND type = " + MailItem.TYPE_MESSAGE);
    public static void alterUnread(MailItem item, boolean unread)    throws ServiceException {        Mailbox mbox = item.getMailbox();        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        try {            String relation;            if (item instanceof VirtualConversation)  relation = "id = ?";            else if (item instanceof Conversation)    relation = "parent_id = ?";            else if (item instanceof Folder)          relation = "folder_id = ?";            else if (item instanceof Flag)            relation = "flags & ?";            else if (item instanceof Tag)             relation = "tags & ?";            else                                      relation = "id = ?";            stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(item) +                    " SET unread = ?, mod_metadata = ?, change_date = ?" +                    " WHERE " +                    (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") +                    "unread = ? AND " + relation + " AND type = " + MailItem.TYPE_MESSAGE);            int pos = 1;            stmt.setInt(pos++, unread ? 1 : 0);            stmt.setInt(pos++, mbox.getOperationChangeID());            stmt.setInt(pos++, mbox.getOperationTimestamp());            if (DebugConfig.enableMailboxGroup)                stmt.setInt(pos++, mbox.getId());            stmt.setInt(pos++, unread ? 0 : 1);            if (item instanceof Tag)                stmt.setLong(pos++, ((Tag) item).getBitmask());            else if (item instanceof VirtualConversation)                stmt.setInt(pos++, ((VirtualConversation) item).getMessageId());            else                stmt.setInt(pos++, item.getId());            stmt.executeUpdate();        } catch (SQLException e) {            throw ServiceException.FAILURE("updating unread state for item " + item.getId(), e);        } finally {            DbPool.closeStatement(stmt);        }    }