1

我正在使用hibernate 3,下面的方法一次可以完美运行,但是第二次使用另一种方法调用它时,我收到一条错误消息:

16:51:45,371 INFO  [org.hibernate.type.IntegerType] (http-localhost-127.0.0.1-8081-2) could not bind value '812' to parameter: 2; java.lang.String cannot be cast to java.lang.Integer

16:51:45,442 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/sg].[Faces Servlet]] (http-localhost-127.0.0.1-8081-2) "Servlet.service()" pour la servlet Faces Servlet a généré une exception: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer

由于调试模式,我已经验证并且代码实际上是一个整数,我不明白为什么错误消息是关于字符串的。

谢谢。


   public BureauModification getDerniereModification(Integer code) {
        List listBureau = getHibernateTemplate().findByNamedQueryAndNamedParam("bureau.detail.last", "codeBureau", code); 



            if (!listBureau.isEmpty()) {
                return (BureauModification) listBureau.get(0);
            }
            return null;
        }


    <query name="bureau.detail.last"
        comment="Détail d'un bureau à partir du code Bureau">
        <![CDATA[FROM BureauModification WHERE (code, dateMiseAJour) IN (SELECT code, MAX(dateMiseAJour) FROM BureauModification WHERE code = :codeBureau GROUP BY code)]]>
    </query>

完整的堆栈跟踪:

17:21:11,467 INFO  [org.hibernate.type.IntegerType] (http-localhost-127.0.0.1-8081-6) could not bind value '812' to parameter: 2; java.lang.String cannot be cast to java.lang.Integer
17:21:11,507 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http-localhost-127.0.0.1-8081-6) #{fusionCreationBean.create}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer: javax.faces.FacesException: #{fusionCreationBean.create}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357) [tomahawk20-1.1.13.jar:1.1.13]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
Caused by: javax.faces.el.EvaluationException: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]
    ... 24 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
    at org.hibernate.type.IntegerType.set(IntegerType.java:41) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:107) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:755) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1143) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) [hibernate3.jar:3.2.4.sp1]
    at org.springframework.orm.hibernate3.HibernateTemplate$33.doInHibernate(HibernateTemplate.java:938) [spring-2.0.3.jar:2.0.3]
    at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367) [spring-2.0.3.jar:2.0.3]
    at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQueryAndNamedParam(HibernateTemplate.java:929) [spring-2.0.3.jar:2.0.3]
    at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQueryAndNamedParam(HibernateTemplate.java:919) [spring-2.0.3.jar:2.0.3]
    at fr.perso.pri.core.dao.impl.CaisseRegionaleModificationDAOImpl.getDerniereModification(CaisseRegionaleModificationDAOImpl.java:77) [classes:]
    at fr.perso.pri.core.service.impl.FusionServiceImpl.loadListeCR2(FusionServiceImpl.java:288) [classes:]
    at fr.perso.pri.core.service.impl.FusionServiceImpl.create(FusionServiceImpl.java:166) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:299) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139) [spring-2.0.3.jar:2.0.3]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) [spring-2.0.3.jar:2.0.3]
    at com.sun.proxy.$Proxy21.create(Unknown Source)
    at fr.perso.pri.web.beans.FusionCreationBean.create(FusionCreationBean.java:116) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    ... 25 more

17:21:11,592 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/sg].[Faces Servlet]] (http-localhost-127.0.0.1-8081-6) "Servlet.service()" pour la servlet Faces Servlet a généré une exception: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
    at org.hibernate.type.IntegerType.set(IntegerType.java:41) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:107) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:755) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1143) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114) [hibernate3.jar:3.2.4.sp1]
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) [hibernate3.jar:3.2.4.sp1]
    at org.springframework.orm.hibernate3.HibernateTemplate$33.doInHibernate(HibernateTemplate.java:938) [spring-2.0.3.jar:2.0.3]
    at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367) [spring-2.0.3.jar:2.0.3]
    at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQueryAndNamedParam(HibernateTemplate.java:929) [spring-2.0.3.jar:2.0.3]
    at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQueryAndNamedParam(HibernateTemplate.java:919) [spring-2.0.3.jar:2.0.3]
    at fr.perso.pri.core.dao.impl.CaisseRegionaleModificationDAOImpl.getDerniereModification(CaisseRegionaleModificationDAOImpl.java:77) [classes:]
    at fr.perso.pri.core.service.impl.FusionServiceImpl.loadListeCR2(FusionServiceImpl.java:288) [classes:]
    at fr.perso.pri.core.service.impl.FusionServiceImpl.create(FusionServiceImpl.java:166) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:299) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139) [spring-2.0.3.jar:2.0.3]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) [spring-2.0.3.jar:2.0.3]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) [spring-2.0.3.jar:2.0.3]
    at com.sun.proxy.$Proxy21.create(Unknown Source)
    at fr.perso.pri.web.beans.FusionCreationBean.create(FusionCreationBean.java:116) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_21]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357) [tomahawk20-1.1.13.jar:1.1.13]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
4

0 回答 0