]
Steve Ebersole resolved HHH-5370.
---------------------------------
Resolution: Fixed
Building IN condition with CriteriaBuilder providing collection of
values not working.
--------------------------------------------------------------------------------------
Key: HHH-5370
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5370
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager, query-criteria
Affects Versions: 3.5.3
Reporter: bogdan
Assignee: Steve Ebersole
Fix For: 3.6, 3.5.x
Time Spent: 47m
Remaining Estimate: 0h
Building IN condition with CriteriaBuilder providing collection of values not working.
Given:
Join<CommissionPo, AreaPo> ca;
List<Long> unitAreaIds;
calling
ca.get(AreaPo_.id).in(unitAreaIds);
ends with:
java.lang.IllegalArgumentException: Unaware how to convert value [[1006, 1008, 1009,
1013, 1011, 1010, 1012] : java.util.ArrayList] to requested type [java.lang.Long]
at
org.hibernate.ejb.criteria.ValueHandlerFactory.unknownConversion(ValueHandlerFactory.java:259)
at
org.hibernate.ejb.criteria.ValueHandlerFactory.access$000(ValueHandlerFactory.java:35)
at
org.hibernate.ejb.criteria.ValueHandlerFactory$LongValueHandler.convert(ValueHandlerFactory.java:153)
at
org.hibernate.ejb.criteria.ValueHandlerFactory$LongValueHandler.convert(ValueHandlerFactory.java:140)
at org.hibernate.ejb.criteria.predicate.InPredicate.<init>(InPredicate.java:126)
at org.hibernate.ejb.criteria.predicate.InPredicate.<init>(InPredicate.java:105)
at org.hibernate.ejb.criteria.CriteriaBuilderImpl.in(CriteriaBuilderImpl.java:577)
at org.hibernate.ejb.criteria.expression.ExpressionImpl.in(ExpressionImpl.java:91)
as a workaround we can call:
ca.get(AreaPo_.id).in(unitAreaIds.toArray());
Cause (varargs missuse):
org.hibernate.ejb.criteria.expression.ExpressionImpl.in(Collection<?>)
calls
org.hibernate.ejb.criteria.CriteriaBuilderImpl.in(Expression<? extends Object>,
Object...)
as result whole collection from ExpressionImpl goas as single parameter to
CriteriaBuilderImpl.in
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: