Re: EOAndQualifier on child entity property
Re: EOAndQualifier on child entity property
- Subject: Re: EOAndQualifier on child entity property
- From: Yann Bizeul <email@hidden>
- Date: Fri, 18 Aug 2006 23:38:50 +0200
This makes me wonder whether you have modeled the Location <<->>
Tag relationship correctly. Using EOModeler's join in many-to-many
relationship functionality, you should end up with:
Location <->> LocationTag <<-> Tag
EOModeler will flatten the Location.locationTags and
LocationTag.tag relationships into Location.tags.
Yes, that's exactly what I have
Assuming that the tag value is in the Tag.tag attribute, then
you'd want all Locations whose tags.tag array contains both "tag1"
and "tag2". My experience in trying to construct an EOQualifier
that accurately describes this requirement hasn't been good.
Writing the SQL that would select the correct locations makes my
head spin :-) Alexander Spohr's GROUP BY and HAVING is probably
headed in the right direction. The SQL might be something as ugly
as the following (totally untested and likely invalid :-)
SELECT t1.id FROM Location t1, LocationTag t2, Tag t3 WHERE t1.id =
t2.locationId AND t2.tagId = t3.id AND (t3.tag = "tag1" OR t3.tag =
"tag2") GROUP BY t1.id HAVING COUNT(t1.id) = 2
Is there a way to "map" that query so that it fits in a EOQualifier
and returns Location objects ?
EOF can't generate such a query by default. However, the query
might suggest an EOF strategy. You could fetch all Locations whose
tags.tag array contains a certain tag value. Then repeat the fetch
for each different tag value. Concatenate the fetched Locations
into a single array, sort by Location, then iterate the array
keeping any Location whose count in the array is the same as the
number of different tag values. Ugly! Anyone else have a better
suggestion?
That is what I was afraid to do, and since I can have thousands of
locations, I guess this will end in terrible performances...
Thank you
Yann Bizeul • yann at tynsoe.org
Cocoa Developer
Tynsoe Projects
BuddyPop • GeekTool • SSH Tunnel Manager • ...
http://projects.tynsoe.org/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden