You cannot convert BooleanExpression to CollectionExpression for the same reasons why you cannot convert java.lang.Boolean to java.util.Collection. They are incompatible.
What would the following expression mean to you
QEvent.event.organization.in( QOrganization.organization.country.in("India", "USA"))
Perhaps you are trying to express something like this?
QEvent event = QEvent.event; QOrganization organization = QOrganization.organization; query.from(event) .innerJoin(event.organization, organization) .where(organization.country.in("India", "USA")) .list(event);
Or easier
QEvent event = QEvent.event; query.from(event) .where(event.organization.country.in("India", "USA")) .list(event);
I assume that you tried to describe this expression using subqueries. Something like that
query.from(event) .where(event.organization.in( subQuery().from(organization) .where(organization.country.in("India", "USA"))) .list(event);
The subQuery () implementation is specific to Querydsl. If you use a connection, you get a row for each combination of the corresponding events - organizations, and with subqueries you get unique events that have organizations that satisfy the given restrictions.
The performance differences for the join vs subquery are implementation specific.
Which Querydsl backend are you using? Jpa, sql or something else?
source share