public static void setParent(MailItem parent, MailItem[] children) throws ServiceException { Mailbox mbox = parent.getMailbox(); Connection conn = mbox.getOperationConnection(); PreparedStatement stmt = null; try { stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(parent) + " SET parent_id = ? WHERE id IN " + suitableNumberOfVariables(children)); int arg = 1; if (parent == null || parent instanceof VirtualConversation) stmt.setNull(arg++, Types.INTEGER); else stmt.setInt(arg++, parent.getId()); for (int i = 0; i < children.length; i++) stmt.setInt(arg++, children[i].getId()); stmt.executeUpdate(); } catch (SQLException e) { throw ServiceException.FAILURE("adding children to parent " + parent.getId(), e); } finally { DbPool.closeStatement(stmt); }
public static void setParent(MailItem parent, MailItem child) throws ServiceException { setParent(parent, new MailItem[] { child });
    public static void setParent(MailItem parent, MailItem[] children) throws ServiceException {        Mailbox mbox = parent.getMailbox();        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        try {            stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(parent) +                    " SET parent_id = ? WHERE id IN " + suitableNumberOfVariables(children));            int arg = 1;            if (parent == null || parent instanceof VirtualConversation)                stmt.setNull(arg++, Types.INTEGER);            else                stmt.setInt(arg++, parent.getId());            for (int i = 0; i < children.length; i++)                stmt.setInt(arg++, children[i].getId());            stmt.executeUpdate();        } catch (SQLException e) {            throw ServiceException.FAILURE("adding children to parent " + parent.getId(), e);        } finally {            DbPool.closeStatement(stmt);        }    }