0 Replies Latest reply on Mar 4, 2016 10:13 AM by kirenpillay1

    Adding Users to Group and Querying a User's Group

    kirenpillay1

      HI

      I'm using PL 2.5.4 (Jboss EAP 6) and have the following questions:

       

      1. I add a user to a group, however when I immediately query the user, I'm unable to retrieve the Group the user is assigned to. The bean is a stateless bean.

       

       

      @Inject

          private IdentityManager identityManager;

      @Inject

          private RelationshipManager relationshipManager;

       

      ADD:

             BasicModel.addToGroup(relationshipManager, user, group); //SuccesFul, see hibernate log below

       

      Query:

      user = BasicModel.getUser(

                      identityManager, username)

               RelationshipQuery<GroupMembership> query = relationshipManager

                      .createRelationshipQuery(GroupMembership.class);

              query.setParameter(Grant.ASSIGNEE, user);

              List<GroupMembership> result = query.getResultList();   // This returns 0 results

       

       

       

       

      16:53:28,300 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: insert into AttributedTypeEntity (id) values (?)

      16:53:28,314 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: insert into IdentityTypeEntity (createdDate, enabled, expirationDate, partition_id, typeName, id) values (?, ?, ?, ?, ?, ?)

      16:53:28,324 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: insert into AccountTypeEntity (email, firstName, lastName, loginName, id) values (?, ?, ?, ?, ?)

      16:53:28,334 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: select accounttyp0_.id as col_0_0_ from AccountTypeEntity accounttyp0_ inner join IdentityTypeEntity accounttyp0_1_ on accounttyp0_.id=accounttyp0_1_.id inner join AttributedTypeEntity accounttyp0_2_ on accounttyp0_.id=accounttyp0_2_.id inner join PartitionTypeEntity partitiont1_ on accounttyp0_1_.partition_id=partitiont1_.id inner join AttributedTypeEntity partitiont1_1_ on partitiont1_.id=partitiont1_1_.id where partitiont1_.id=? and accounttyp0_1_.typeName=? and accounttyp0_.loginName=?

      16:53:28,355 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: select attributet0_.id as id1_1_, attributet0_.name as name2_1_, attributet0_.owner_id as owner_id5_1_, attributet0_.typeName as typeName3_1_, attributet0_.value as value4_1_ from AttributeTypeEntity attributet0_ where attributet0_.owner_id=?

      16:53:34,945 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: select relationsh0_.id as id1_2_0_, relationsh0_.typeName as typeName1_12_0_ from RelationshipTypeEntity relationsh0_ inner join AttributedTypeEntity relationsh0_1_ on relationsh0_.id=relationsh0_1_.id where relationsh0_.id=?

      16:53:34,975 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: select next_val as id_val from hibernate_sequence for update

      16:53:34,982 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: update hibernate_sequence set next_val= ? where next_val=?

      16:53:34,992 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: select next_val as id_val from hibernate_sequence for update

      16:53:34,999 INFO  [stdout] (http-localhost/127.0.0.1:7080-2) Hibernate: update hibernate_sequence set next_val= ? where next_val=?

      16:53:35,005 DEBUG [org.picketlink] (http-localhost/127.0.0.1:7080-2) Firing event [org.picketlink.idm.event.RelationshipCreatedEvent@2625b050].