QueryTransformer addWhere as 'or'

Jmix version: 2.3.0
Jmix Studio plugin version: 2.3.0-241
IntelliJ IDEA 2024.1 (Ultimate Edition)

Hi Jmix team.

We know that, it is possible to add a where clause to a query through the QueryTransformer. But it is added as and operation by default. Like:

QueryTransformer queryTransformer = queryTransformerFactory.transformer(“select e from jb_Entity e order by e.sort”);
queryTransformer.addWhere(“e.sort > :sort”);

Can we add it as or?.

1 Like

Is there any news on it?

Hello Abdulmalik,

There is no out of the box way to add where clause through QueryTransformer with or operation.

It will be easier to use Conditions if it is possible to process query conditions before any where clause added to it.

Otherwise, if you can’t avoid modifying the where that already exists in the query, you can extend io.jmix.data.impl.jpql.transform.QueryTransformerAstBased and io.jmix.data.impl.jpql.transform.QueryTreeTransformer#mixinWhereConditionsIntoTree to make own addWhereWithOr() method, but this can be quite time consuming and may require additional support if something changes for these classes in future releases.

Regards,
Dmitry