[Hibernate-JIRA] Created: (HHH-3520) wrongly predicted param type in HQL
by Gregory Klimov (JIRA)
wrongly predicted param type in HQL
-----------------------------------
Key: HHH-3520
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3520
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.1
Reporter: Gregory Klimov
Consider class CategoryCode class with property 'code' of type Integer. Then such a code snippet:
Query query1 = session.createQuery("from CategoryCode where 'Hello world!' + code + 14 = ?");
query1.setParameter(0, "Test");
query1.list();
Its execution produces sql (which is absolutely correct):
select
...
from
category_codes categoryco0_
where
'Hello world!'+categoryco0_.code+14=?
but mapping parameter gives error:
20:21:01,504 <> [main] INFO IntegerType:140 - could not bind value 'Test' to parameter: 1; java.lang.String cannot be cast to java.lang.Integer
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at org.hibernate.type.IntegerType.set(IntegerType.java:41)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
at org.hibernate.param.PositionalParameterSpecification.bind(PositionalParameterSpecification.java:39)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:491)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1563)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 2 months