Re: EOAndQualifier on child entity property
Re: EOAndQualifier on child entity property
- Subject: Re: EOAndQualifier on child entity property
- From: Alexander Spohr <email@hidden>
- Date: Fri, 18 Aug 2006 09:31:24 +0200
Am 18.08.2006 um 01:47 schrieb Sacha Michel Mallais:
On Aug 17, 2006, at 4:04 PM, Yann Bizeul wrote:
Say an entity MyEntity, having a many-to-many relationship with a
Tag entity, the purpose of that is tagging MyEntity with one or
more keywords (tags)
Now I want to get all MyEntity having "tag1" AND "tag2" as tags.
An EOAndQualifier is nonsense in the result sql since if queries
"tag1" = "tag1" AND "tag1" = "tag2", EOOrQualifier is not better
since I need to match entries having *both* tags
you need to GROUP BY HAVING. and eof can not do that out of the box.
tip 1:
select them with OR
GROUP BY tag
HAVING COUNT 2 (in your demo it is 2)
alternative (not recommended):
make a second entity of the same Tag-table named Tag2.
then try relationshipToTag.tag = "tag1" AND relationshipToTag2 = "tag2"
this should give a select-statement with two different table-aliases
for the tag-table. that worked some years ago, but only with two
tags. if you need three tags you need another Entity and so on. don't
do it this way :)
Try "myAttribute CONTAINS %s AND myAttribute CONTAINS %s" for a
format string, with params of "tag1" and "tag2", as in (warning,
untested code):
EOQualifier q = EOQualifier.qualifierWithQualifierFormat
("myAttribute CONTAINS %s AND myAttribute CONTAINS %s", new NSArray
(new Object[] {tag1, tag2}));
that does not work either as it just constructs an equal unusable and-
clause.
atze
_______________________________________________
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