How do we query users in Jmix?

On our login screen, we have a need to use dataManager or another facility to query users. This all worked fine in CUBA. After migration to Jmix, it isn’t working; we’re getting a No Results exception.

A simple test like this:

        List<User> users = dataManager.load(User.class)
                .query("select u from sec$User u")
        for (User u : users) {
  ">>> User: [{}]", u.getUsername());

… is returning an empty list???

This is just after migration from CUBA. It was all working fine in CUBA.

This is fairly puzzling…

Hi @modemmisuser

The DataManager uses the security mechanism by default. In the Login screen, we are as an anonymous user, apparently he does not have enough rights to read the User entity. Alternatively, you can set permissions or use:

List users = dataManager.unconstrained().load(User.class)
.query(“select u from sec$User u”)
.list();">>> UsersListSize: [{}]", users.size());
for (User u : users) {">>> User: [{}]", u.getUsername());