Group filtering by the same property issue

Hello,

I am currently working on creating a group filter based on a date property. The conditions involve checking for dates that are greater than or equal to a certain value and, simultaneously, less than or equal to another value. However, I’ve encountered an issue where the SQL query seems to use only the first value for both conditions, resulting in no returned results.

I would appreciate any insights or suggestions on how to resolve this matter.

Thank you.

sql-problem
image

Hello Iliyan,

The best option is to attach a simple example project with steps to reproduce the issue, so I can check the reason of it.

If it is not convenient or not possible, please provide next information:

  1. version of Jmix,
  2. source code of the screen (at least parts related to group filter and parts which can affect entity loading on this screen),
  3. date property definition in entity,
  4. full log related to troubled query.

As for now, without additional information, it makes sense to put breakpoint inside the io.jmix.core.impl.UnconstrainedDataManagerImpl#loadList and look into passed LoadContext: are condition and parameters correct?

Regards,
Dmitry

Hello Dmitry,

We’ve successfully replicated this behavior on Jmix versions 1.3 and 1.5. It doesn’t seem to be related to the screen, and there are no exceptions caused by incorrect queries. Instead, I believe it’s a platform issue, because this is out of the box group filter.

I placed a breakpoint where you advised, and the screenshot below indicates that it’s employing the same value for both conditions, which is unexpected.

image

Hello Iliyan,

I’ve tried to reproduce this situation on new Jmix project, but, unfortunately had no luck:

genFilterBugNotReproduced.zip (110.5 KB)

I’ve tried xml definition, manual creation, saving and loading configurations at runtime - still no progress.
Parameter names was different in my simple case:
Снимок экрана 2023-11-23 в 19.10.03

Could you please provide steps or attach a project to reproduce the issue?

Regards,
Dmitry

Hi Dmitry,

I’ve identified the issue. Both filters are producing the same parameter name. Any thoughts on why this might be happening? :slight_smile:

image

Regards,
Iliyan

Hello Iliyan,

If I understand you correctly, it looks like org.apache.commons.lang3.RandomStringUtils issue in your environment.

Please try to put a breakpoint at io.jmix.core.querycondition.PropertyConditionUtils#generateParameterName:59.

  • Does RandomStringUtils.randomAlphabetic(8) returns the same value each time?

If so, please, run the next test:

//...
import org.apache.commons.lang3.RandomStringUtils;
import java.util.Random;
//...

    @Test
    void test_random() {
        log.info("First RandomStringUtils value: " + RandomStringUtils.randomAlphabetic(8));
        log.info("Second RandomStringUtils value: " + RandomStringUtils.randomAlphabetic(8));

        Random random = new Random();

        log.info("First Random value: " + random.nextInt(20));
        log.info("Second Random value: " + random.nextInt(20));
    }

Which values does it print?

Regrads,
Dmitry

Hello Dmitry,

Yes, every time it returns the names of the properties. So it is the same.
The issue is that the generated names of the params, which are used in the SQL are also the same.

The result of the test:

14:25:30.652 [main] INFO com.fsc.internal.portal.service.servicerequest.db.PrcReportCheckProcedure - First RandomStringUtils value: FmZOipql
14:25:30.657 [main] INFO com.fsc.internal.portal.service.servicerequest.db.PrcReportCheckProcedure - Second RandomStringUtils value: FYYigVRo
14:25:30.661 [main] INFO com.fsc.internal.portal.service.servicerequest.db.PrcReportCheckProcedure - First Random value: 19
14:25:30.661 [main] INFO com.fsc.internal.portal.service.servicerequest.db.PrcReportCheckProcedure - Second Random value: 8

Hello Iliyan,

Sorry for the late reply. The whole situation looks strange.
In case of RandomStringUtils.randomAlphabetic(8) always returns the same symbols at io.jmix.core.querycondition.PropertyConditionUtils#generateParameterName:59 it makes sense to debug how are these symbols generated at this line. Maybe something wrong happens with org.apache.commons.lang3.RandomStringUtils#RANDOM ?

Does the same situation occurs on another computers, OS, JDK? Is some kind of virtualisation used?
If so, which configurations are affected?
If it is possible to reproduce the problem on another computer, could you, please, make a simple reproducible example and post it?

Regards,
Dmitry

Hello Dmitry,

I see that these parameter names are generated once here:

io.jmix.ui.component.propertyfilter.PropertyFilterConverter#convertToComponent

and afterwards are just used for the corresponding prop. Is there anything that I am missing

image

Best regards,
Iliyan

Hello Iliyan,

As I can see, io.jmix.ui.component.propertyfilter.PropertyFilterConverter#convertToComponent does not create parameter name by itself but uses model.getParameterName() instead. Parameter name for model is generated by PropertyConditionUtils#generateParameterName.

Please, check again whether RandomStringUtils.randomAlphabetic(8) returns the same values at io.jmix.core.querycondition.PropertyConditionUtils#generateParameterName:59 for two consecutive calls?

If not, could you please clarify what was meant by this reply

Yes, every time it returns the names of the properties. So it is the same.

If yes, and the same value returned for two different properties at line io.jmix.core.querycondition.PropertyConditionUtils#generateParameterName:59 please, check whether this problem occurs in another environment:

  1. Another JDK
  2. Another computer

If yes, please, provide a minimal reproducible example.

Regards,
Dmitry