Domanda

We're migrating a project from hibernate 1 to hibernate 3.3.1, and we're a problem with some Querys:

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long

The code that we have now, used to work with hibernate 1 but get the exception above with hibernate 3.3.1, the piece of code is:

        if(args!=null){
            for(int i=0; i<args.length; i++)
                queryObject.setParameter(i, args[i]);
        }

args is a Object[]

and the Query is, for example:

select obj.oid,obj.codTipoTrafico,obj.nomEmpresaOper,obj.codOrigen,obj.codFuente,obj.codIdnFuente,to_char(obj.fecFuente,'DD/MM/YYYY') from OperacionComercial obj where obj.indTpoOper = ? and obj.oidEmpresa = ? order by  order by obj.oca desc

Hibernate cannot autoconvert from String to Long no more?

Thanks in advance

È stato utile?

Soluzione

Changing the hibernate configuration property "hibernate.query.factory_class" to use the ClassicQueryTranslator for the HQL, the problem is solved...(at least for me).

<props>
     <prop key="hibernate.query.factory_class">
          org.hibernate.hql.classic.ClassicQueryTranslatorFactory
    </prop>
</props>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top