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?
|