-->
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: Query for several collection values w/o huge no. of joins
PostPosted: Tue Sep 20, 2005 6:24 pm 
Beginner
Beginner

Joined: Wed Jul 21, 2004 6:50 pm
Posts: 27
Hi,

I'm still trying to figure out how to query for an object that has several specified matches in it's collection object.

So, say I have a Feature which has multiple Settings. I simply want to find the Features where the Settings are equals to "A", "B", "C" and "D".

I can do this with multiple joins on Settings, but doesn't seem like the right way to go when you're looking for upto 7 Settings, something like:

SELET f FROM
Feature f INNER JOIN f.settings s1
INNER JOIN f.settings s2
INNER JOIN s.settings s3
INNER JOIN s.settings s4
WHERE s1.value = "A" AND
s2.value = "B" AND
s3.value = "C" AND
s4.value = "D".

Surely there's a better way? We have the added complication that we have a Printer object that has Feature collection which have Settings collection, and we have to search for Feature-Setting combinations. Thus we end up with a HUGE query of joins.

cheers,

David


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 9:22 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
I think you'd have same number of joins if you did direct sql. If you can't avoid the joins using direct sql, you can't avoid them using hibernate.

The only option is to change the data model, or view of the data model.


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.