-->
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.  [ 1 post ] 
Author Message
 Post subject: left join does not returnall entities of left table
PostPosted: Tue Nov 13, 2012 5:43 am 
Newbie

Joined: Tue Jan 31, 2012 3:44 pm
Posts: 7
Hi,

the following query is not working as I expected it to:
Code:
select distinct image
from Image as image
left outer join image.properties as property
where lower(image.displayname) like lower('%[filter]%')
or lower(property.value.value) like lower('%[filter]%')


I expect it to return all entities of Image that either have a displayname that returns true on
Code:
lower(image.displayname) like lower('%[filter]%')

even if there are no properties assigned to it, or have Property entities assigned with a value that returns true on
Code:
lower(property.value.value) like lower('%[filter]%')


Everything works fine except I do not get any Image entities with no Property entities assigned, even if the displayname returns true on
Code:
lower(image.displayname) like lower('%[filter]%')




As an example. There are the following entities:
Code:
abstract class Resource {
    List<Property> properties;
    String displayname;
}

class Image extends Resource {
}

class Property {
    Value value;
}

class Value {
    String value;
}


And I have the following data:
Code:
valueA (value = "hello")
propA (value = valueA)
valueB (value = "testValue")
propB (value = valueB)
imageA (displayname = "hello", properties = null)
imageB (displayname = "test", properties = {propA})
imageC (displayname = "hello", properties = {propB})


then the query with [filter] substituted by 'hello' would only return imageB and imageC, even though imageA meets the required
Code:
lower(image.displayname) like lower('%[filter]%')


hopefully someone understood my problem and is able to give me a hint on how to solve this.
Thank you in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.