"(SELECT " + (DebugConfig.enableMailboxGroup ? "?, " : "") + "?, type, ?, ?, ?, ?, date, size, ?, blob_digest, unread," + " flags, tags, sender, subject, ?, ?, ?, ? FROM " + table + " WHERE " + (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") + "id = ?)");
"(SELECT " + (DebugConfig.enableMailboxGroup ? "?, " : "") + " ?, type, ?, ?, ?, ?, date, size, ?, blob_digest, unread," + " flags, tags, sender, subject, ?, ?, ?, ? FROM " + table + " WHERE " + IN_THIS_MAILBOX_AND + "id = ?)");
    public static void copy(MailItem item, int id, Folder folder, int indexId, int parentId, short volumeId, String metadata)    throws ServiceException {        Mailbox mbox = item.getMailbox();        if (id <= 0 || folder == null || parentId == 0)            throw ServiceException.FAILURE("invalid data for DB item copy", null);        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        try {            String table = getMailItemTableName(mbox);            stmt = conn.prepareStatement("INSERT INTO " + table +                    "(" +                    (DebugConfig.enableMailboxGroup ? "mailbox_id, " : "") +                    "id, type, parent_id, folder_id, index_id, imap_id, date, size, volume_id, blob_digest," +                    " unread, flags, tags, sender, subject, metadata, mod_metadata, change_date, mod_content) " +                    "(SELECT " +                    (DebugConfig.enableMailboxGroup ? "?, " : "") +                    "?, type, ?, ?, ?, ?, date, size, ?, blob_digest, unread," +                    " flags, tags, sender, subject, ?, ?, ?, ? FROM " + table + " WHERE " +                    (DebugConfig.enableMailboxGroup ? "mailbox_id = ? AND " : "") +                    "id = ?)");            int mboxId = mbox.getId();            int pos = 1;            if (DebugConfig.enableMailboxGroup)                stmt.setInt(pos++, mboxId);            stmt.setInt(pos++, id);                            // ID            if (parentId <= 0)                stmt.setNull(pos++, Types.INTEGER);            // PARENT_ID null for messages in virtual convs            else                stmt.setInt(pos++, parentId);                  //   or, PARENT_ID specified by caller            stmt.setInt(pos++, folder.getId());                // FOLDER_ID            stmt.setInt(pos++, indexId);                       // INDEX_ID            stmt.setInt(pos++, id);                            // IMAP_ID is initially the same as ID            if (volumeId >= 0)                stmt.setShort(pos++, volumeId);                // VOLUME_ID specified by caller            else                stmt.setNull(pos++, Types.TINYINT);            //   or, no VOLUME_ID            stmt.setString(pos++, checkTextLength(metadata));  // METADATA            stmt.setInt(pos++, mbox.getOperationChangeID());   // MOD_METADATA            stmt.setInt(pos++, mbox.getOperationTimestamp());  // CHANGE_DATE            stmt.setInt(pos++, mbox.getOperationChangeID());   // MOD_CONTENT            if (DebugConfig.enableMailboxGroup)                stmt.setInt(pos++, mboxId);            stmt.setInt(pos++, item.getId());            int num = stmt.executeUpdate();            if (num != 1)                throw ServiceException.FAILURE("failed to create object", null);        } catch (SQLException e) {            // catch item_id uniqueness constraint violation and return failure            if (e.getErrorCode() == Db.Error.DUPLICATE_ROW)                throw MailServiceException.ALREADY_EXISTS(id, e);            else                throw ServiceException.FAILURE("copying " + MailItem.getNameForType(item.getType()) + ": " + item.getId(), e);        } finally {            DbPool.closeStatement(stmt);        }    }