-->
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: Selecting Unique Results
PostPosted: Wed May 14, 2008 5:26 am 
Newbie

Joined: Wed May 14, 2008 5:19 am
Posts: 1
Hibernate version: 1.2.1

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

String sql = "select distinct u.name as name, c.courseId as courseId from ELUnit as u inner join u.parentCourse as c";

Query query = (Query) session.createQuery(sql);

for (Iterator iterator = query.iterate(); iterator.hasNext();) {
Object[] row = (Object[]) iterator.next();
elCourseList.put((String)row[0], (String)row[1]);
}

Name and version of the database you are using:
MySQL 5.0.45 Community Edition

The generated SQL (show_sql=true):

select distinct elunit0_.name as col_0_0_, elcourse1_.courseId as col_1_0_ from ELUNIT elunit0_ inner join ELCOURSE elcourse1_ on elunit0_.courseId=elcourse1_.id inner join ELUNIT elcourse1_1_ on elcourse1_.id=elcourse1_1_.elUnitId


My Query is giving me duplicate results. How to get Unique results?


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