-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unable to get a Distinct query with multiple select entities
PostPosted: Fri Mar 16, 2007 4:46 am 
Newbie

Joined: Mon Nov 21, 2005 6:15 am
Posts: 14
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2.1ga

I am unable to get a distinct query with multiple entities in HQL to work. It looks like,

select distinct (emp, dept)
from Employee emp, Department dept, Lines l, Costs c
where emp.lid = l.id
and l.cid = c.id
and c.did = dept.id

I would expect to get a list of distinct (emp, dept) combinations in the returned list. However I am getting exceptions like "Expected CLOSE but found a ,"

Firstly, Am I doing the wrong thing in trying to select a distinct tuple of entities. If no, how is this being achieved in Hibernate?


Top
 Profile  
 
 Post subject: In case it helps
PostPosted: Fri Mar 16, 2007 4:56 am 
Newbie

Joined: Mon Nov 21, 2005 6:15 am
Posts: 14
I am attaching the actual SQL queries that got executed,

select
top ? distinct emp5_.id
...
....

With whatever little of SQL that I know, the query should be select "distinct top ? ". A bit of googling pointed me to http://jira.nhibernate.org/browse/NH-829. Could someone tell me if they are related? (It is NHibernate, alright :) )


Top
 Profile  
 
 Post subject: I am attaching a set FirstResult and setMaxResults
PostPosted: Fri Mar 16, 2007 5:05 am 
Newbie

Joined: Mon Nov 21, 2005 6:15 am
Posts: 14
Apologies for not stating this earlier, I do a

Query q = session.createQuery(..from the string pasted..);
q.setFirstResult(10);
q.setMaxResults(10);

That is throwing the above SQL with the misplaced "distinct" word


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.