JPA: contains()/in() don't work for member collections

Bug #847607 reported by Maia Everett
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Won't Fix
Undecided
Unassigned

Bug Description

I have two classes with a one-to-many association through a List. When I try to make a query using contains() or in() with the member collection, JPAQuery generates an IN ELEMENTS() query, which is Hibernate-specific. Instead, it should use MEMBER OF, which is part of the JPA standard.

As a workaround, currently I use the reverse mapping reference for comparison, i.e. q2.parent.eq(q1) instead of q1.children.contains(q2) or q2.in(q1.children). Still not very clean.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

The JPAQuery uses HQLTemplates by default because we prioritize Hibernate compatibility. For JPA 2 standard compliant JPQL use JPQLTemplates.DEFAULT instead.

e.g.

JPAQuery query = new JPAQuery(entityManager, JPQLTemplates.DEFAULT);

Changed in querydsl:
status: New → In Progress
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Maia, does the proposed solution work for you?

Revision history for this message
Maia Everett (linneris) wrote :

Haven't tested. I'll do so tomorrow. (I also think the documentation should clearly state the fact that a Hibernate-compatible mode is used by default. Implementation independence is the whole point of the JPA standard.)

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Yes, you are right. I just updated the documentation concerning this.

Changed in querydsl:
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.