[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5238) On setting a String-Value for a integer entity-field in a criterion, produces a ClassCastException

Hannes Havel (JIRA) noreply at atlassian.com
Thu May 20 01:51:12 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37218#action_37218 ] 

Hannes Havel commented on HHH-5238:
-----------------------------------

Hi Gail,

I am not sure that you have undestoud my request.

In this case the string consists only numbers and representing a integer number of e.g. "10"  and this can be converted to a integer 10 and i am not speaking about to convert a text string to an integer.   

JDBC an do this easily.

Is hibernate so restricted ?

How you can establish a generalized query interface where only strings are transported and the provided service has no knowledge about the queried entities and the datatypes of the fields. 
So i think a automatic conversion of a string representing a number to the nhumber type and so on is a esential funktionality for a 
data sorage and retrieve interface.

BR
Hannes Havel

> On setting a String-Value for a integer entity-field in a criterion, produces a ClassCastException
> --------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5238
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5238
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.1
>            Reporter: Hannes Havel
>            Assignee: Gail Badner
>
> 12:06:40,864  INFO          http-8080-2 IntegerType:158 - could not bind value '10' to parameter: 1; java.lang.String cannot be cast to java.lang.Integer
> 12:06:40,865 DEBUG          http-8080-2 ServletServiceContainer:179 - core-exception in service-execution: null
> java.lang.reflect.InvocationTargetException
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at com.daotec.remoting.server.ServiceMethod.invoke(ServiceMethod.java:85)
>         at com.daotec.remoting.server.ServletServiceContainer.doPost(ServletServiceContainer.java:168)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
>         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
>         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>         at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
>         at org.hibernate.type.IntegerType.set(IntegerType.java:64)
>         at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
>         at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
>         at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1728)
>         at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1699)
>         at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
>         at org.hibernate.loader.Loader.doQuery(Loader.java:696)
>         at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
>         at org.hibernate.loader.Loader.doList(Loader.java:2228)
>         at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
>         at org.hibernate.loader.Loader.list(Loader.java:2120)
>         at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
>         at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
>         at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
>         at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
>         at com.daotec.foundation.hibernate.GenericHibernateDAO.countAll(GenericHibernateDAO.java:147)
>         at com.daotec.remoting.utils.CoreGenericDAOService.list(CoreGenericDAOService.java:108)
>         ... 20 more

-- 
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

        


More information about the hibernate-issues mailing list