Potential bug in repository method

Hello! I’ve discovered a potential bug (or at least it seems to be one, as the behavior is unexpected).
Environment:

  • Java Version: 17
  • Jmix Version: 1.5.4
  • Previous Working Environment: Java 11 with Jmix 1.3.5

When I invoke the repository method, for instance, findAllByIdAndClientId(null, existedUUID);, it does not attempt to find an entity using both conditions (and hence, returns no result as one might expect). Instead, it only searches for entities that match the second condition (clientId). Here is the generated SQL:

eclipselink.logging.sql - <t 281095450, conn 911204301> SELECT ID, CREATED_BY, CREATED_DATE, LAST_MODIFIED_BY, LAST_MODIFIED_DATE, NAME, VERSION, CLIENT_ID, RECYCLE_BIN_ID FROM CLIENT_AGREEMENTS WHERE (CLIENT_ID = ?)
bind => [83210e7d-81fd-11ee-80de-ac1f6bd82839]

However, it functions correctly if I use the @Query annotation instead of the generated repository code:

@Query("select ca from ClientAgreements ca where ca.id = :agreementId and ca.client.id = :clientId")
Stream<ClientAgreements> findAllByIdAndClientId(UUID agreementId, UUID clientId);

This behavior was not observed in our previous setup (Java 11 with Jmix 1.3.5), suggesting that it might be a regression or an unintended side-effect of the upgrade.

1 Like

Hello Ignat,

This is indeed the issue, thank you for reporting it!

For now, the easiest workaround is to use @Query.

Regards,
Dmitry

1 Like