-->
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: outer join question
PostPosted: Mon Jun 27, 2005 10:31 pm 
Newbie

Joined: Tue May 10, 2005 5:23 am
Posts: 3
I have a HQL statement like this:
"from Course_Info as c, Courses as s
where c.id = s.courseId and s.courseCode = 13 order by c.id"

I didnot define any association between Course_Info and Courses.
Now the problem is that I want to use left outer join.
because there is no association between Course_Info and Courses.
I cannot use HQL like this "from Course_Info as c left join Courses as s
where s.courseCode = 13 order by c.id".

the Native SQL createSQLQuery(String , String, Class) only accept one class, but I want to get two class, Course_Info and Courses. just like my first HQL statement does.

_________________
jackj


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 8:42 am 
Regular
Regular

Joined: Thu Apr 29, 2004 5:08 pm
Posts: 56
Location: Montreal, Quebec, Canada
First, why don't you actually declare the association between the two entities in your mappings?

Second, your HQL query should read

Code:
from Course_Info ci left join ci.course c where c.courseCode = 13 order by ci.id


Don't forget to put the resulting List in a Set to eliminate potential duplicates...

_________________
- Frank


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.