.class parameter in HQL query not converted into discriminator value properly
-----------------------------------------------------------------------------
Key: HHH-1836
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1836
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.0.5
Environment: Win XP SP2, Hibernate 3.0.5, Sun Java 1.5.0_06
Reporter: Ignat Zapolsky
Hello!
I have following problem:
when using HQL query
"select item.id, item.name from Item as item where item.class = ?"
and trying to use clause Query.setParameter (0, SubItem.class)
I am getting following exception from underlying database since hibernate doese not properly convert parameter into associated discriminator value:
2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000>
2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000>
2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item">
2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item">
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select abstractco0_.id as col_0_0_, abstractco0_.name as col_1_0_ from TABLE abstractco0_ where abstractco0_.type=?]; SQL state [37000]; error code [-16]; Wrong data type: For input string: "Item"; nested exception is java.sql.SQLException: Wrong data type: For input string: "Item
java.sql.SQLException: Wrong data type: For input string: "Item"
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source)
at org.hibernate.type.StringType.set(StringType.java:24)
at org.hibernate.type.ClassType.set(ClassType.java:35)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:44)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1115)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1177)
at org.hibernate.loader.Loader.doQuery(Loader.java:390)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
Please also examine bug http://opensource.atlassian.com/projects/hibernate/browse/HHH-1749 it observes situation from discriminatort to class point of view.
PS. There are several forum posts regarding almost same issues:
http://forum.hibernate.org/viewtopic.php?t=956408&highlight=discriminator+hql
http://forum.hibernate.org/viewtopic.php?t=941125&highlight=discriminator+class+name+hql
PPS. If required I could provide sample mappings and code snippets.
--
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.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
|