<!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;">
    Violation of UNIQUE KEY constraint with sub-process
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/RyanLBart">Ryan Bartlett</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/556328#556328">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I am getting the following Exception when using sub-processes (.jpdl.xml files are below). I have removed the subprocesses and everything works fine. When I add them back in, I get the ConstraintViolation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My environment is using MSSQL Server and we have not modified any of the JBPM defaults for transactions, id generators, etc. Any clues? I have seen some other posts regarding this issue, but haven't seen a clear answer except for perhaps there is a bug in the id generator.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="color: #ff0000;">Starting execution:</span></p><p><span style="font-size: 10pt;"><p align="left">ProcessInstance processInstance = executionService.startProcessInstanceByKey(message.getClass().getCanonicalName(), <em><span style="font-size: 10pt;"> parameters);</span><span style="font-size: 10pt;"> <em style=": ; font-size: 2; "><p align="left"><p align="left">String processInstanceId = processInstance.getId();</p><p align="left">IMessage response = (IMessage) executionService.getVariable(processInstanceId, <em><span style="color: #0000c0; font-size: 10pt; ">S_MESSAGE_RESPONSE</span><span style="font-size: 10pt;">);</span><span style="font-size: 10pt;"> <em style=": ; font-size: 2; "><p align="left"><p align="left"> <em style="font-size: 10pt; ">executionService.endProcessInstance(processInstanceId, <span style="color: #2a00ff; font-size: 10pt; ">"end"</span><span style="font-size: 10pt;">);</span></em></p></p></em></span></em></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></p></em></span></em><em><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></em></p></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="color: #ff0000;">Stack trace:</span></p><p>2010-08-06 18:15:49,686 ERROR bus.thread.pool-1-message.processing.thread-1 org.hibernate.util.JDBCExceptionReporter - Violation of UNIQUE KEY constra<br/>int 'UQ__JBPM4_EXECUTION__67C95AEA'. Cannot insert duplicate key in object 'dbo.JBPM4_EXECUTION'.<br/>2010-08-06 18:15:49,686 ERROR bus.thread.pool-1-message.processing.thread-1 org.hibernate.event.def.AbstractFlushingEventListener - Could not synchron<br/>ize database state with session<br/>org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="color: #ff0000;">Main JPDL file:</span></p><p>&lt;process name='com.e3.es.order.messages.createorder.defn.v2.CreateOrderRequestType' <br/> key='com.e3.es.order.messages.createorder.defn.v2.CreateOrderRequestType' <br/>id='create'&gt;<br/> &lt;start&gt;<br/>&#160; &lt;transition to='beginProcessing'/&gt;<br/> &lt;/start&gt;</p><p><br/> &lt;java name='beginProcessing'<br/>&#160; class='com.e3.es.order.service.jbpm.handler.RequestHandler'<br/>&#160; method='getProcessingContext'<br/>&#160; var='processingContext'&gt;<br/>&#160; &lt;arg&gt;&lt;object expr='#{serviceRequest}'/&gt;&lt;/arg&gt;<br/>&#160; &lt;transition to='verify'/&gt;<br/> &lt;/java&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> &lt;sub-process name='verify' sub-process-key="supply.verify"&gt;<br/>&#160; &lt;parameter-in var="processingContext" subvar="processingContext" /&gt;<br/>&#160; &lt;transition to='holdPurchases'/&gt;<br/> &lt;/sub-process&gt;</p><p> <br/>&lt;java name='holdPurchases'<br/>&#160; class='com.e3.es.order.service.jbpm.handler.general.AdaptorRequestHandler'<br/>&#160; method='handle'&gt;<br/>&#160; &lt;arg&gt;&lt;string value='hold'/&gt;&lt;/arg&gt;<br/>&#160; &lt;arg&gt;&lt;object expr='#{processingContext}'/&gt;&lt;/arg&gt;<br/>&#160; &lt;arg&gt;&lt;string value='Role=RequestedProductDetail;ProcessingModel=Two-Phase'/&gt;&lt;/arg&gt;<br/>&#160; &lt;transition to='wait'/&gt;<br/> &lt;/java&gt;</p><p> &lt;state name='wait'/&gt;</p><p>&lt;end name='end'&gt;&lt;/end&gt;</p><p>&lt;/process&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="color: #ff0000;">Subprocess:</span></p><p>&lt;process name='supply.verify' key='supply.verify'&gt;<br/> &lt;start&gt;<br/>&#160; &lt;transition to='supplyverify'/&gt;<br/> &lt;/start&gt;</p><p> &lt;java name='supplyverify'<br/>&#160; class='com.e3.es.order.service.jbpm.handler.general.AdaptorRequestHandler'<br/>&#160; method='handle'&gt;<br/>&#160; &lt;arg&gt;&lt;string value='verify'/&gt;&lt;/arg&gt;<br/>&#160; &lt;arg&gt;&lt;object expr='#{processingContext}'/&gt;&lt;/arg&gt;<br/>&#160; &lt;arg&gt;&lt;string value='Role=RequestedProductDetail,PaymentPlan'/&gt;&lt;/arg&gt;<br/>&#160; &lt;transition to='end'/&gt;<br/> &lt;/java&gt;<br/> &lt;end name='end'&gt;&lt;/end&gt;<br/>&lt;/process&gt;</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/556328#556328">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>