-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: findByNamedQueryAndNamedParam classcastexception
PostPosted: Mon Oct 07, 2013 11:00 am 
Newbie

Joined: Mon Oct 07, 2013 10:45 am
Posts: 1
I am using hibernate 3, and my method below will work perfectly one time, but the second time when it is called with another method I obtain an error message :

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

I have verified thanks to debug mode and code is really an integer, I don't understrand why the error message is speaking about a string.

Thanks.

_________________________________________________


Code:
       public BureauModification getDerniereModification(Integer code) {
            List listBureau = getHibernateTemplate().findByNamedQueryAndNamedParam("bureau.detail.last", "codeBureau", code);
     
   
             
                if (!listBureau.isEmpty()) {
                    return (BureauModification) listBureau.get(0);
                }
                return null;
            }



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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.