Hibernate version: 3.0.5
I use a filter in entity MyEntity.hbm.xml :
<filter name="gidFilter" condition="GID like :gid"/>
The HQL is:
select e.id from MyEntity as e where e.param1 like ? and e.param2 = (select e1.param2 from MyEntity as e1 where e1.id = ? )
The Generated SQL is correct. But the result is null!
If I modify the HQL to:
select e.id from MyEntity as e where e.param1 like 'abc' and e.param2 = (select e1.param2 from MyEntity as e1 where e1.id = '10001' )
All is correct!!
I debug the program with hibernate source,and found that hibernate has something wrong when set the parameter values. It sets the wrong order of the parameters.
Let's look some source of hibernate:
class: org.hibernate.engine.QueryParameters
method: processFilters(String sql, SessionImplementor session)
line number: 366
source: parameters.addAll( Arrays.asList( getPositionalParameterValues() ) );
Hibernate process filter ,and set the filter's parameters first. And add all other parameters simply after sets the filter. So maybe it has the wrong order of parameters.
Maybe it's a bug of hibernate.
|