5 Replies Latest reply on Apr 17, 2007 8:18 PM by Peter Ottomanelli

    Problem Creating ProcessInstance

    Marcos Chicote Newbie

      Hi, the code is like this:

       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       ProcessInstance instance = jbpmContext.newProcessInstance("DefinitionName");
       jbpmContext.close();
      


      When it inserts the first ProcessInstance (first in the table, id = 1) it runs fine.
      When I tried to insert a second ProcessInstance it fails:

      Hibernate:
       insert
       into
       JBPM_PROCESSINSTANCE
       (VERSION_, KEY_, START_, END_, ISSUSPENDED_, PROCESSDEFINITION_, ROOTTOKEN_, SUPERPROCESSTOKEN_)
       values
       (?, ?, ?, ?, ?, ?, ?, ?) select
       scope_identity()
      14:56:33,140 [main] WARN JDBCExceptionReporter : SQL Error: 2627, SQLState: 23000
      14:56:33,140 [main] ERROR JDBCExceptionReporter : [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Violation of UNIQUE KEY constraint 'UQ__JBPM_PROCESSINST__731B1205'. Cannot insert duplicate key in object 'JBPM_PROCESSINSTANCE'.
      14:56:33,140 [main] WARN JDBCExceptionReporter : SQL Error: 3621, SQLState: HY000
      14:56:33,140 [main] ERROR JDBCExceptionReporter : [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The statement has been terminated.
      Exception in thread "main" org.jbpm.persistence.JbpmPersistenceException: couldn't assign id to org.jbpm.graph.exe.ProcessInstance@16de067
      


      Violation of unique key constrain? In JBPM_PROCESSINSTANCE table the id has identity "yes" (autonumeric), in the hibernate entity configuration file for ProcessInstance the id is "native", even in the executed sql there's no ID for insert. So, what's happening? It should insert a row with id=2 but it says that the id is duplicated.

      Thanks!