I read a good portion of the documentation and forums topics however I’m stuck with my ‘issue’.
I would like to recover the user details (entity object data) that you can find in the session so that I can use it for business logic & querying related data based on some additional metadata fields.
I’m currently not finding a good or best practice approach
I got this code now, which works however as is normal with spring boot security, I only have the fields available that are part of userDetails.
I have something in the documentation about querying custom data but I’m missing a small link the the jpa repository of userservice that i can use to do a findbyId()
Which would be the recommended way in jmix to do this?
When you need to get the current Tenant, just invoke a JPQL query with DataManager:
@Autowired
private DataManager dataManager;
User currentUser = ...;
Tenant tenant = dataManager.load(Tenant.class)
.query("select t from User u, Tenant t where u.tenant = t and u.id = :userId")
.parameter("userId", currentUser.getId())
.optional()
.orElse(null);
This operation can be extracted into Spring bean for convenient use.