-->
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.  [ 2 posts ] 
Author Message
 Post subject: distinct in HQL fails when setMaxResults on query is set
PostPosted: Thu Jan 13, 2005 10:55 pm 
Newbie

Joined: Wed Jun 30, 2004 4:50 am
Posts: 12
Hibernate version: 2.1.4

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: DB2/NT 8.1.2

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Hi all,

I have a parent child relationship where parent has set of children (bi-directional one-to-many).
I am trying retreive parent objects by child attributes using HQL. As relation from parent to child is 1-*
I am getting duplicate parent objects and when I apply distinct key word I am getting expected results.
But as the query results could be big I need to apply setMaxResults on the query but this is causing problem.
It distincts over rownumber() rather than parent Id again I am getting duplicate results.


My HQL looks as below


select distinct c.parent
from com.abc.Child c
where c.attr1 = ?


Without setMaxResults() on Query it works fine but not when it is applied..
generated SQL for DB2 is as below


select * from ( select rownumber() over() as row_,...) ) as temp_ where row_ <= ?



Anyone have any suggestions on how to avoid duplicates.Thanks you all.



Regards,
Surya


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 10:58 pm 
Newbie

Joined: Wed Jun 30, 2004 4:50 am
Posts: 12
sorry generted SQL is as below

select * from ( select distinct rownumber() over() as row_,...) ) as temp_ where row_ <= ?


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.