Hello,
I have a Jmix 1.5+ project with the following screen xml descriptor:
<loader id="userEntitiesDl">
<query>
<![CDATA[select e from UserEntity e order by e.createdDate desc]]>
<condition>
<and>
<c:jpql>
<c:where>e.manager = :manager</c:where>
</c:jpql>
</and>
</condition>
</query>
</loader>
And the Java class that handles it:
@Override
protected void initActions(InitEvent event) {
super.initActions(event);
if (event.getOptions() instanceof UsersForManagerScreenOptions options) {
this.usersForManagerScreenOptions = options;
this.userEntitiesDl.setParameter(PARAM_MANAGER, usersForManagerScreenOptions.getManager());
}
}
In the same screen I have a filter which allows a manager to apply all sorts of filters against the users that they manage (the users are displayed in a GroupTable):
<filter id="filter" dataLoader="userEntitiesDl">
<properties include="username"/>
<configurations>
<configuration id="filterUserNameConfiguration"
default="true"
name="Filter-User-By-Username">
<propertyFilter id="pfUsername" property="username"
operation="CONTAINS"
operationEditable="false"
caption="Search User By Username"/>
<propertyFilter id="pfFirstName" property="firstName"
operation="CONTAINS"
operationEditable="false"
caption="Search User By First Name"/>
.........
</configuration>
</configurations>
</filter>
Once the screen is opened the global JPQL where clause gets applied and the manager user sees only the employees they manage. As soon as they apply any filtering on the result set though, the JPQL condition gets ignored and the filter is applied on all users in the DB. Thus, after filtering they actually get a bigger dataset and they can see users that they don’t manage / are not supposed to view.
My question is - How can I apply the global JPQL where clause AFTER each application of the user filter at runtime?
Looking forward to any help or advice.