4 Replies Latest reply on Feb 3, 2010 4:04 AM by protocol7

    Persisting Hibernate entities as process variables

      Hi

       

      As part of a jBPM4 prototype I'm working on, I would like to add instances of a custom class as process variables. I've created a Hibernate mapping definition and also confirmed that it works as expected when persisting this using the Hibernate API directly. However, when adding my instance as a variable, the following exception is thrown (tested with 4.2 and 4.3):

      Exception in thread "main" org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: se.vgregion.rosproto.model.Issue

       

      A reference to the Hibernate mapping has been added to the jBPM Hibernate configuration file (I use the same file when using Hibernate directly).

       

      Do I need to persist the object myself before adding it as a variable or I'm I missing something obivous here? (I'm guessing the latter :-)

       

      Here's the code I'm using, based on jbarrez Hello world example.

       

      {code}

      ProcessEngine processEngine = new Configuration().setResource("my.jbpm.cfg.xml").buildProcessEngine();

      RepositoryService repositoryService = processEngine.getRepositoryService();

      ExecutionService executionService = processEngine.getExecutionService();

       

      repositoryService.createDeployment().addResourceFromClasspath("hello_world.jpdl.xml").deploy();

               
      Issue issue = new Issue();

      issue.setRequestor("req");

      issue.setResponder("resp");

       

      ProcessInstance instance = executionService.startProcessInstanceByKey("helloWorld");

      executionService.setVariable(instance.getId(), "issue", issue);

      {code}