<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Cancel a process throws exceptions
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/matrixpooh">Al Nadein</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/558638#558638">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In my application, I'd like to be able to delete open (pending) process instances. My process instances usually consists of 2-8 subprocesses. The delete of the parent should be able to cascade delete its forked executions and its sub-processes, their forked children and their subprocesses. I'm running into</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#23]<br/>&#160;&#160;&#160; at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)<br/>&#160;&#160;&#160; at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)<br/>&#160;&#160;&#160; at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2559)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>when doing a cascade delete. Seems that the process attempts to delete the parent record immediately, without looking for children processes.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Below is the complete unit test to reproduce the issue:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Your input would be highly appreciated.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>package workflow;import java.util.HashMap;import java.util.Map;import junit.framework.Assert;import org.jbpm.api.Configuration;import org.jbpm.api.Execution;import org.jbpm.api.ExecutionService;import org.jbpm.api.IdentityService;import org.jbpm.api.ProcessEngine;import org.jbpm.api.ProcessInstance;import org.jbpm.api.RepositoryService;import org.jbpm.api.activity.ActivityExecution;import org.jbpm.api.cmd.Command;import org.jbpm.api.cmd.Environment;import org.junit.After;import org.junit.Before;import org.junit.Ignore;import org.junit.Test;import org.slf4j.Logger;import org.slf4j.LoggerFactory;public class OpenProcessWithinProcessTest {&#160;&#160;&#160; private static final Logger log = LoggerFactory.getLogger(OpenProcessWithinProcessTest.class);&#160;&#160;&#160; &#160;&#160;&#160; public IdentityService identityService ;&#160;&#160;&#160; public ExecutionService executionService;&#160;&#160;&#160; public RepositoryService repositoryService;&#160;&#160;&#160; &#160;&#160;&#160; static final String XML_MAIN = "(){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @Override&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; public Void execute(Environment environment) throws Exception {&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ((ActivityExecution)processInstance1).end(Execution.STATE_ENDED);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return null;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }});&#160;&#160;&#160; &#160;&#160;&#160; }}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/558638#558638">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>