0 Replies Latest reply on Dec 4, 2007 2:24 AM by hans meier

    Copy a ProcessDefinition from one Database to another

    hans meier Newbie

      In our project we use several different databases to store ProcessDefinitions, and we are now looking for a way to load a ProcessDefinition from database A and store it in database B. We first tried to simply pass it like this:

      // get the target jbpm context
      JbpmContext j = getTargetJbpmContext();
      
      // load process definitions
      processDefinitions = getJbpmContext().getGraphSession().findLatestProcessDefinitions();
      
      processMap = new HashMap();
      
      // deploy process definitions
      for(Iterator iter = processDefinitions.iterator(); iter.hasNext();){
       ProcessDefinition pd = (ProcessDefinition)iter.next();
       j.deployProcessDefinition(pd);
      }
      


      This does not work because hibernate throws this:
      org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions


      We also tried to serialize and deserialize the object and load the deserialized object in the db, but due to hibernates internal way to store objects on a database this also does not really work, because it inserts a child before a parent what results in a db error because of the RI. This would be avoidable by running the RI-Check only at commit, but that would affect in several dependencies so we couldn't change that.

      We also tried to clone the object using the SerializationHelper class, but due to hibernates lazy loading this didn't clone the hole object because not everything was loaded.

      We also couldn't use the xml-description of the processDefinition and parse it again, because if we have to keep them we have a lot of redundant data.

      so is there a way to copy a processDefinition from one database to another?

      thanks in advance