-->
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: Does it use subquery?
PostPosted: Fri May 19, 2006 12:58 am 
Newbie

Joined: Fri May 19, 2006 12:34 am
Posts: 1
I have 2 object: Teacher and Student, they are many-to-many relationship. In Tearcher class it has a list of Students. I try to make a hql query to get all the teachers which have a student's name as "Peter". Currently I have 2 queries have seems to work properly:
1. select distinct t from Teacher t, Student s where s.name="Peter" and s=any elements(t.students)
2. select distinct t from Teacher t join t.students s where s.name="Peter"

Actually I didn't expect the second query can work before, but tried and it worked. I know elements(t.students) in the first query actually is a subquery, but not sure about the second one. Is anyone know how it worked and is it a subquery?
Many Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 19, 2006 12:50 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Make sure the "show_sql" property is set to "true" and examine generated SQL in the log.

Curtis

_________________
---- Don't forget to rate! ----


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.