Hi all.
Does anyone know why in a query with a indexed collection causes a bad order parameter binding?
This is my example:
Named query:
Code:
select a
from Actividad a, DefinicionActividad da
where a.definicionActividad = da
and a.proceso = :idProceso
and (da.atributos[:nombre] = :dato)
Code used to execute it with Hibernate 3.0.5:
Code:
Query queryObject = session.getNamedQuery(queryName);
queryObject.setParameter("idProceso", 3);
queryObject.setParameter("nombre", "PREGUNTA");
queryObject.setParameter("dato", "TIPO_ACTIVIDAD");
SQL query generated in MySQL:
Code:
select ...
from ...
where definicion1_.id=atributos2_.idDefinicionActividad
and atributos2_.[b]nombre[/b] = '3'
and actividad0_.definicionActividad=definicion1_.id
and actividad0_.[b]idProceso[/b] = 'PREGUNTA'
and atributos2_.[b]dato[/b] = 'TIPO_ACTIVIDAD'
Its seems that the "da.atributos[:nombre]" part is correctly translated as "atributos2_.nombre = ?" but placed first in the query, and wrong binded with the first parameter passed: "3" and ignoring the name of that parameter.
It happens too without using named parameters and using "da.atributos[?]" instead.
It happen with the ASTQueryTranslatorFactory and the old ClassicQueryTranslatorFactory (pre 3.0) parser, but the last one can not handle indexed collections in subqueries either (
http://opensource.atlassian.com/projects/hibernate/browse/HHH-310).
Thanks in advance.