-->
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: hql on a many to many association
PostPosted: Mon Jan 10, 2005 12:41 pm 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
I have entity Student and Course, in a many-to-many association.
The linking entity is Payment.
All this entity has surrogated id as primary key.

I want to get all the students that are not associated to a specific course.
How to do it in HQL?

I tried something like

select s from Student s, Course c, Payment p where c = :course and (p.course <> c and p.student = s)

but doesn't return the student with no entry in payment table.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 10, 2005 1:58 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
This is not peculiar to HQL. You need to explicitly outer join if you are looking for rows that don't exist.


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.