-->
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: One Question regarding HQL
PostPosted: Thu Mar 08, 2007 6:05 am 
Beginner
Beginner

Joined: Mon Aug 22, 2005 9:57 pm
Posts: 27
Dear All

I have a question regarding HQL as below.


Customer:Contact is 1:1
Contact:Address is 1:n
Address:PhoneAdress is 1:1
Address:PostAddress is 1:1
PhoneAddress.medium is "PHONE"
PostAddress.medium is "MAIL"
PhoneAddress and PostAddress are both subclass of Address

I just need to find Customer who has no PhoneAddress
For example , if a Customer having both PhoneAddress and PostAddress
,then this Customer could not appear in selected Result.
How to create this in HQL?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 12, 2007 11:02 am 
Beginner
Beginner

Joined: Mon Aug 22, 2005 9:57 pm
Posts: 27
I already have the working SQL

select c.customer_id from test.customer c
inner join test.contact contact_ on c.customer_id= contact_.contact_id
left outer join test.address a on a.contactaddress= contact_.contact_id and a.medium = "PHONE" where a.address_id is null

But I could not convert this SQL to HQL successfully.
because I fail to left outer join only with Address which is 'PHONE'

Anyone could give me some hints how to convert above SQL to HQL?


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.