-->
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: query question
PostPosted: Tue Mar 03, 2009 5:45 am 
Newbie

Joined: Tue Mar 03, 2009 5:36 am
Posts: 2
hi - i am having hard time translating the following regular sql..

select * from vb_product p left outer join (select * from vb_product_privilege where organization_id = 1) as pp on p.id = pp.product_id where p.name like 'ms%'

my initial attempt to word it like follows applies the organization 'filter' to end result so it does not return all records from product as a left outer join should..

select distinct p, opl.privilege from Product p left outer join p.organizationPrivilegeList opl where p.name like 'ms%' and opl.organization.id = 1

any idea is appreciated, thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 6:00 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
hmm, if opl.organization.id is not nullable you could try to add an or to your statement: where p.name like 'ms%' and (opl.organization.id = 1 or opl.organization.id is null)

Otherwise use the "with" keyword to supply extra join conditions: left outer join p.organizationPrivilegeList opl with opl.organization.id = 1

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: problem solved
PostPosted: Tue Mar 03, 2009 7:10 am 
Newbie

Joined: Tue Mar 03, 2009 5:36 am
Posts: 2
afaik "with" is not a valid keyword with ejb3 jpa but "or opl.organization.id is null" did the trick.. thanks.


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.