-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Incorrect when use filter with subselect!
PostPosted: Sat Oct 08, 2005 4:36 am 
Newbie

Joined: Tue Jun 14, 2005 2:04 am
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.