0 Replies Latest reply on Mar 15, 2006 11:14 AM by Rolf Schuster

    Context variables aren't being updated in the DB

    Rolf Schuster Newbie

      Hi,

      I have some custom class:

      public class Dummy implements Serializable {
       public String text;
      
       public Dummy(String text) { this.text = text; }
      
       public boolean equals(Object obj) {...}
      
       public int hashCode() { ... }
      
       public String toString() { return text; }
      }
      


      Then I create a process instance and put a Dummy object into the context:

      processInstance_.getContextInstance().setVariable("dummy", new Dummy("at start"));
      


      After that, I load process instance (in another transaction/JbpmContext), call signal() on its root token
      and modify the dummy object within an ActionHandler which runs in the same process instance/token:

      Dummy d = (Dummy) executionContext.getContextInstance().getVariable("dummy");
      d.text = "step 2";



      Problem 1: when I close the jbpm context, the variable isn't being updated in the database (even with equals() and hashCode() implemented).
      Only when I "re-set" the variable after modifying the dummy object:

      executionContext.getContextInstance().setVariable("dummy", d);


      It gets saved. But when I save a Java primitive or a LinkedList for example as the variable, then it get's saved automatically.
      What do I have to do so my objects get saved automatically after modifying them?


      Problem 2: the rows in the jbpm_byteblock aren't updated (most of the time), but when I save an existing processinstance, the modified variables are serialized into a newrow, rather than updating the existing row for the same process instance/token.
      So for example when I have a java.util.List saved as a context variable and i modify it, it gets serialized into a new row and the old row from jbpm_byteblock isn't referenced anymore in the DB (as far as I can tell) so it isn't needed.

      How can I achieve that all the context variables are updated in the database rather than being saved as new rows?

      Thanx in advance