cancel
Showing results for 
Search instead for 
Did you mean: 

Group Membership cannot be created with identity service

srón
Champ in-the-making
Champ in-the-making
I want to bring about tasks belonging to a group with members (with identityservice.createMembership("admin", "XXX"):smileywink:



    for (Task task : tasks) {

      if( identityservice.createGroupQuery().groupName("GROUP_XXX").count()==0){
      identityservice.newGroup("GROUP_1_PRODUKTAPPLIKATEUR");
    }

      if(!identityservice.createGroupQuery().list().contains(identityservice.createGroupQuery().groupId("GROUP_1_PRODUKTAPPLIKATEUR")
                 .groupMember("admin"))){
            identityservice.createMembership("admin", "XXX");
      }

      taskService.claim(task.getId(), "GROUPXXX");
}


…but I always get an error stack:


Caused by: org.apache.ibatis.exceptions.PersistenceException:

. . .

### The error may involve org.activiti.engine.impl.persistence.entity.MembershipRelation.insertMembership-Inline
### The error occurred while setting parameters
### SQL: insert into ACT_ID_MEMBERSHIP (USER_ID_, GROUP_ID_)     values (       ?,       ?     )



Integrity constriant violated, superordinate key not found. The group is not there in the database. I do not know what the reason of this error might be, does anyone have an idea?
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

one example from jUnit tests:

    Group sales = identityService.newGroup("sales");
    identityService.saveGroup(sales);
    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
   
    // Create the membership
    identityService.createMembership(johndoe.getId(), sales.getId());

Regards
Martin