From: Max R. A. (JIRA) <no...@at...> - 2006-07-07 14:34:38
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-699?page=all ] Max Rydahl Andersen closed HBX-699: ----------------------------------- Fix Version: 3.2beta6 Resolution: Cannot Reproduce please test against latest Hibernate being bundled with the tools ...and if it still existi please open a case with a simple mapping example that fails. > Incorrect code generation for query-param elements > -------------------------------------------------- > > Key: HBX-699 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-699 > Project: Hibernate Tools > Type: Bug > Components: hbm2java > Versions: 3.2beta6 > Environment: Hibernate 3/MySql 5.X > Reporter: Jak Mang > Fix For: 3.2beta6 > > > Query params in xml mapping files generate incorrect code for integers and possibly other scalers. In the case below, > I have tried "int", "integer", "Integer" and "java.lang.Integer" and "Ljava.lang.Integer;" for the type of parameter "region". > <query name="com.tgcusa.idmgr.ProgramId.findProgramId"> > <query-param name="region" type="integer"/> > <query-param name="epgser" type="string"/> > <query-param name="epgepi" type="string"/> > <![CDATA[ > select pid.tgcsh, pid.tgcser, pid.tgcepi from com.tgcusa.idmgr.ProgramId > as pid where pid.region == :region and pid.epgser == :epgser and > pid.epgepi = :epgepi > ]]> > </query> > The code generator always produces: > public List findTgcSerForEpgSer(int region, java.lang.String tepgser) > { > Query query = > sessionFactory.getCurrentSession().getNamedQuery("com.tgcusa.idmgr.ProgramId.findTgcSerForEpgSer"); > query.setParameter("region", region); > query.setParameter("tepgser", tepgser); > return query.list(); > } > Which has the compilation error: > [javac] Found 2 semantic errors compiling "/sandbox/mainline/srcroot/sw/tgcs > vc/lib/java/src/com/tgcusa/idmgr/ProgramIdHome.java": > [javac] 171. query.setParameter("region", region); > [javac] ^----------------------------------^ > [javac] *** Semantic Error: No applicable overload for a method with signatu > re "setParameter(java.lang.String, int)" was found in type "org.hibernate.Query" > . Perhaps you wanted the overloaded version "org.hibernate.Query setParameter(ja > va.lang.String $1, java.lang.Object $2) throws org.hibernate.HibernateException; > " instead? > It seems that: > 1) There is ambiguity about the type "integer". I have seen it generate java.lang.Integer in other code. > 2) for "int", a query.setParameter should support int. > 3) for an Integer object, the setParameter call is ok, but the the method parameter shoud be Integer not int. -- 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 |