1 Reply Latest reply on Feb 20, 2010 10:22 AM by kukeltje

    Storing java.util.Collection on process

    rubenbentein

      I have a question about a best practise concerning processes with a dynamic list as a variable.

       

      Let's say for example i have an process which has to store 0..* objects as variables. I.e. an process B

       

      public class B{

           string b1;

           string b2;

           java.util.Collection<A> aCollection;

      }

       

      and a class A


      public class A{

           string a1;

           string a2;

      }

       


      so before calling

       

      executionService.startProcessInstanceByKey("B-process-name", variables);

       

      I have to fill the variables map. But how should i add aCollection ? Should i do something like


      variables.put("b1", someBObject.b1);

      variables.put("b2", someBObject.b2);

      for (int i=0 ; i<someBObject.aCollection.size() ; i++){

           variables.put("aCollection[" + i + "].a1", aCollection.get(i).a1);

           variables.put("aCollection[" + i + "].a2", aCollection.get(i).a2);

      }

       

      Or maybe there is a better/cleaner solution.

      Or should i store these object in my own tables, and just store a reference (id) on the variables list ?

       

      Thanks for any replies