Enums in HQL contains

Bug #800698 reported by Samppa Saarela
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

Hibernate cannot guess sqlType of an enum parameter in ":x in elements(enumCollection)" -clauses. It falls back to binary type where it should use enums ordinal or name depending on property mapping. It seems that in this case analyzing type is too hard from the query itself: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5159 .

Querydsl should record enum type (string or ordinal) to EnumPath and convert enum parameters directly to integer or string before calling Hibernate's Query.setParameter(name, value).

Revision history for this message
Samppa Saarela (samppa-saarela) wrote :

As annotation processor and query types (EnumPath) are general, it hardly seems appropriate to put there some Hibernate-bug-specific hacks. Could this be worked around like...

1) Collect all property related annotations (including @Enumerated) to Path. As these cannot be annotations of the path field itself, the path should provide a method for getting annotations of the original member. In addition to this bug-workaround, these annotations could be used e.g. for validation of (batch) update parameters using validation annotations of the original member. This could be useful for some applications also.

2) In Hibernate specific JPQLSerializer extension visitOperation could check if a) first parameter is an enum constant and b) second argument (e.g. SetPath) has optional @Enumerated annotation. Then it could change the enum constant to ordinal integer or name string before calling super.visitOperation.

?

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

Fixed in SVN trunk

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

Released in 2.2.0

Changed in querydsl:
status: Fix Committed → Fix Released
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.