QueryDSL duplicate identification variable/equality syntax error with any on Set?

后端 未结 2 908
清酒与你
清酒与你 2021-01-24 23:44

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

相关标签:
2条回答
  • 2021-01-25 00:00

    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());
    
    0 讨论(0)
  • 2021-01-25 00:05

    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.

    0 讨论(0)
提交回复
热议问题