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 fetch a collection
PostPosted: Wed Aug 27, 2008 7:46 am 
Newbie

Joined: Thu Jun 19, 2008 4:49 am
Posts: 12
i have a problem fetching a dataobjects collection. let's say we have a UserGroup that contains a collection of Users. when selecting all usergroups, i want to load all users at once. i do

select ug from UserGroup ug left join fetch ug.users

this returns all usergroups not only once, but every single usergroup multiplied with the users.size(). to avoid this, i simple do

select distinct ug from UserGroup ug left join fetch ug.users

it works. i receive all usergroups and users in one single statement.

this is my problem: let's say we have a Resource class that contains a blob and a collection of Users. if i try

select distinct r from Resource r left join fetch r.users

it throws an exception telling me, i cannot use the distinct keyword on an image-stream (blob). how to make sure i only receive every resource once, apart from the size of the users-collection?

i have two workarounds for this (first: load all into a java set; second: wrap the blob in another dataobject BlobObject and referring in the resource to the blobobject.id) but there has to be a simplier way. any suggestions?


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.