0 Replies Latest reply on Nov 6, 2015 5:36 AM by d33pcode

    Can't query Roles from database

    d33pcode
      public List<SelectItem> getRolesList() {
         List<SelectItem> items = new ArrayList<SelectItem>();
         List<Role> roleList = identityManager.getQueryBuilder()
         .createIdentityQuery(Role.class).getResultList();
         for (Role role : roleList) {
         if (role != null)
        items.add(new SelectItem(role.getName()));
         }
         return items;
      
       }
      

       

      'role' is always null. I tried to test exactly the same method with a List instead, and it works (every (User user : userList)  is correctly found).

      identityManager is @Injected; this is its configuration:

       

      @ApplicationScoped
      public class InjectConfiguration {
      
         private IdentityConfigurationBuilder builder;
      
         @PicketLink
         @SuppressWarnings("unchecked")
         @Produces
         public IdentityConfigurationBuilder getIdentityConfigurationBuilder()   {
         if (builder == null) {
        builder = new IdentityConfigurationBuilder();
        builder.named("default.config")
         .stores()
         .jpa()
         .supportType(User.class, Role.class, Group.class,
         Realm.class, Application.class,
         ApplicationRealm.class)
         .supportGlobalRelationship(Grant.class,
         GroupMembership.class, ApplicationAccess.class)
         .supportCredentials(true)
         .mappedEntity(ApplicationAccessTypeEntity.class,
         ApplicationTypeEntity.class,
         ApplicationRealmTypeEntity.class,
         PartitionTypeEntity.class, GrantTypeEntity.class,
         GroupMembershipTypeEntity.class,
         GroupTypeEntity.class, RealmTypeEntity.class,
         RoleTypeEntity.class, UserTypeEntity.class,
         PasswordCredentialTypeEntity.class,
         RelationshipTypeEntity.class,
         RelationshipIdentityTypeEntity.class)
         .addCredentialHandler(PasswordCredentialHandler.class);
         }
         return builder;
      
         }
      }

       

      I can't imagine what the error should be. First, I thought Roles weren't even saved in my db, but SELECT * FROM RoleTypeEntity denied my doubts. The only other thing I could think about was something like some kind of problem with the injection of IdentityManager , but once again, as I said, testing the method with querying users gave me positive results. Any ideas? Thank you in advantage for the help.