In the QueryDSL library, the com.mysema.query.types.expr.SimpleExpression<T> class has a SimpleExpression.in(CollectionExpression<?, ? extends T>) method which is supposed to take an expression which is supposed to return a collection. But I cannot find a way to create an object of type com.mysema.query.types.CollectionExpression<?, ? extends T>.
My query expression looks like this:
QEvent.event.organization.in(expression)
where i want the expression to be something like:
QOrganization.organization.country.in("India", "USA")
But the second expression is of type com.mysema.query.types.expr.BooleanExpression and I am unable to find a way to convert it to com.mysema.query.types.CollectionExpression<?, ? extends T>.
I looked in the QueryDSL API docs but could not find anything relevant.
You can’t convert a BooleanExpression into CollectionExpression, for the same reasons why you can’t convert a java.lang.Boolean into a java.util.Collection. They aren’t compatible.
What would the following expression mean to you
Do you maybe try to express something like this?
Or simpler
I guess what you tried to describe was an Expression using subqueries. Something like this
The implementation of subQuery() is Querydsl backend specific. If you use a join then you get a row for each matching event – organization combination and with subqueries you get unique events which have organizations meeting the given constraints.
Performance differences of join vs subquery are implementation specific.
Which Querydsl backend do you use? JPA, SQL or something else?