-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping nested-query to HQL
PostPosted: Wed Jan 21, 2004 12:46 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
Dear All
This might be a silly question but I couldn't solve it by myself, I have got two table like schema below:


MEMBER(memberId, name, email)
ADDRESS(adressId, memberId, countryCode)


Relation
MEMBER(1)<---memberId--->(1)ADDRESS

I use subquery to get members who have countryCode like, 99, like this

SELECT member FROM MEMBER as member WHERE member.memberId IN(
SELECT address.memberId FROM ADDRESS as address WHERE address.countryCode=99);


I really don't know how to map this to HQL query without using sub-query because MySQL
4.0 still doesnot support sub-query.

Thanks

_________________
<name>arin</name>
<at>netplus software</at>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 1:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You can do a join - but in anycase, HQL will be converted approrpriately to multiple SQLs if subselects are not supported by the dialect. Just try it out and see what is generated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 1:28 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
Oh I C and finally I got it by following this thread

http://forum.hibernate.org/viewtopic.php?t=924769&highlight=subquery

and do something like this for my HQL:

select member from Member as member inner join member.arress as address where address.country = 99");

Thanks for bochi , emmanuel, gavin and MCWelch for finish that useful thread.
Cheers
Cool

_________________
<name>arin</name>
<at>netplus software</at>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.