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>