4 Replies Latest reply on Nov 29, 2005 4:14 AM by babas1

    subgroup question!!!

    afrit

      The Group class has a method addChild.but how do i can create subgroup by that? who's able to give detail information for that using the JBPM identity model?thanks

        • 1. Re: subgroup question!!!
          afrit

          up

          • 2. Re: subgroup question!!!
            kukeltje

            down

            • 3. Re: subgroup question!!!
              aymanson

              I've checked. Here's the code example
              I assume u use the hibernate session from the jbpm session directly
              Session lvSession = lvJbpmSession.getSession();

              // This block will create 2 child groups. Skip if you have created the child group already.
              Transaction lvTransaction1 = lvSession.beginTransaction();
              Group lvChild1 = new Group("child1");
              Group lvChild2 = new Group("child2");
              lvSession.saveOrUpdate(lvChild1);
              lvSession.saveOrUpdate(lvChild2);
              lvTransaction1.commit();

              // Thie block create a parent group and assign 2 childrens
              Group lvGroup = new Group("ParentGroup");
              Query lvQuery = lvSession.createQuery("from Group as group where group.name='child1' or group.name='child2'");
              List lvChildGroup = (List) lvQuery.list();
              Transaction lvTransaction = lvSession.beginTransaction();
              for (Iterator lvIterator = lvChildGroup.iterator(); lvIterator.hasNext();) {
              lvGroup.addChild((Group)lvIterator.next());
              }
              lvSession.saveOrUpdate(lvGroup);
              lvTransaction.commit();

              // don't close the hibernate session.
              //you call JbpmSession.close() as u borrow the hibernate session from it.
              lvJbpmSession.close();


              If u run that and you find that the code is not working. If u take look in the code, the addChild method add it to the field children. But the hibernate mapping file don't have that field. (is that the problem of my JBPM version only??? I am using jbpm-identity-3.0.1.jar)

              You need to modify the Group.hbm.xml and add the following lines.


              <one-to-many class="org.jbpm.identity.Group" />


              You need to update the db schema to make that work.
              BUT I wonder if the identity model expression can support child group membership searching. It seems that the child group support for the identity model is not completed yet.

              • 4. Re: subgroup question!!!

                Does anyone have tried this solution UNTIL the end ?
                It sounds very interesting. As previous reply says, the question really is "is the child group support for the identity model completed or not yet ?"
                If not, is it inserted into Jira as an enhancement ?

                But i am also a beginner with Hibernate.. can you post the new Group.hbm.xml file and the new create table statement with the correction ?

                Thank you.