-->
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: trouble getting result with a set
PostPosted: Mon Mar 01, 2004 4:22 pm 
Newbie

Joined: Mon Mar 01, 2004 3:41 pm
Posts: 9
Hi,

Has anyone experienced the following strange behavior?

When I execute a query like this:

select item.name, elements(item.photos) from Item item left join item.photos where item.id=1

The result is empty if the item does not have any photos; and the result is correct if the item has photos. "Photo" represent another table and is mapped with many-to-one relationship in the Photo class, and a one-to-many set in the Item class.

It doesn't seem to honor "left join" with which i hope to get a row with a value for item.name and a null for item.photos in case there's no photos in the set.

Of course the result is not empty in all cases if the query is selecting everything from Item, e.g. using something like "from Item item..." to start with, but that's not a query i want because i don't want to retrieve other fields including a large text field.

If anyone can tell me why it is so and how to get around the problem, it'll be most appreciated!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 4:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Code:
select item.name, photo from Item item left join item.photos photo where item.id=1


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 5:01 pm 
Newbie

Joined: Mon Mar 01, 2004 3:41 pm
Posts: 9
Thank you, Michael!

That worked. That's fantastic! i've been hanging over this problem for more than a day and was was just ready to switch to bare JDBC :-)


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.