-->
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: usage of Query.setMaxResults ignores distinct keyword in HQL
PostPosted: Mon Jan 31, 2005 4:19 am 
Newbie

Joined: Wed Jun 30, 2004 4:50 am
Posts: 12
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

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:

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 distinct rownumber() over() as row_,...) ) as temp_ where row_ <= ?


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



Regards,


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 9:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This problem cannot be solved in SQL, and hence not in Hibernate.


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.