JBoss Community

Violation of UNIQUE KEY constraint with sub-process

created by Ryan Bartlett in jBPM - View the full discussion

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.

 

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.

 

Thanks!

 

Starting execution:

ProcessInstance processInstance = executionService.startProcessInstanceByKey(message.getClass().getCanonicalName(), parameters);

String processInstanceId = processInstance.getId();

IMessage response = (IMessage) executionService.getVariable(processInstanceId, S_MESSAGE_RESPONSE);

executionService.endProcessInstance(processInstanceId, "end");

 

 

 

Stack trace:

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
int 'UQ__JBPM4_EXECUTION__67C95AEA'. Cannot insert duplicate key in object 'dbo.JBPM4_EXECUTION'.
2010-08-06 18:15:49,686 ERROR bus.thread.pool-1-message.processing.thread-1 org.hibernate.event.def.AbstractFlushingEventListener - Could not synchron
ize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
        at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
        at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
        at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
        at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)

 

 

Main JPDL file:

<process name='com.e3.es.order.messages.createorder.defn.v2.CreateOrderRequestType'
key='com.e3.es.order.messages.createorder.defn.v2.CreateOrderRequestType'
id='create'>
<start>
  <transition to='beginProcessing'/>
</start>


<java name='beginProcessing'
  class='com.e3.es.order.service.jbpm.handler.RequestHandler'
  method='getProcessingContext'
  var='processingContext'>
  <arg><object expr='#{serviceRequest}'/></arg>
  <transition to='verify'/>
</java>

 

<sub-process name='verify' sub-process-key="supply.verify">
  <parameter-in var="processingContext" subvar="processingContext" />
  <transition to='holdPurchases'/>
</sub-process>


<java name='holdPurchases'
  class='com.e3.es.order.service.jbpm.handler.general.AdaptorRequestHandler'
  method='handle'>
  <arg><string value='hold'/></arg>
  <arg><object expr='#{processingContext}'/></arg>
  <arg><string value='Role=RequestedProductDetail;ProcessingModel=Two-Phase'/></arg>
  <transition to='wait'/>
</java>

<state name='wait'/>

<end name='end'></end>

</process>

 

Subprocess:

<process name='supply.verify' key='supply.verify'>
<start>
  <transition to='supplyverify'/>
</start>

<java name='supplyverify'
  class='com.e3.es.order.service.jbpm.handler.general.AdaptorRequestHandler'
  method='handle'>
  <arg><string value='verify'/></arg>
  <arg><object expr='#{processingContext}'/></arg>
  <arg><string value='Role=RequestedProductDetail,PaymentPlan'/></arg>
  <transition to='end'/>
</java>
<end name='end'></end>
</process>

Reply to this message by going to Community

Start a new discussion in jBPM at Community