I have JPA entities as outlined here: QueryDSL JPA syntax error with contains on Set?
Now I try to have multiple restrictions on the Set tags
in a single qu
Currently there are bugs in EclipseLink and QueryDSL that deny usage of the straight forward statements:
q.where(license.tags.any().in(withTags));
q.where(license.tags.any().in(withoutTags).not());
Instead a workaround has to be used:
Collection<Integer> withTagIds = new ArrayList<Integer>();
for (Tag tag : withTags) {
withTagIds.add(tag.getId());
}
q.where(license.tags.any().id.in(withTagIds));
Collection<Integer> withoutTagIds = new ArrayList<Integer>();
for (Tag tag : withoutTags) {
withoutTagIds .add(tag.getId());
}
q.where(license.tags.any().id.in(withoutTagIds ).not());
Can you use a join instead of a sub-select? This would be much more efficient as well.
You could also try EclipseLink 2.4, which may not have these issues.
QueryDSL supports joins, both innerJoin() and leftJoin(), you should use this instead.