Re: Finding an empty to many relationship
Re: Finding an empty to many relationship
- Subject: Re: Finding an empty to many relationship
- From: Chuck Hill <email@hidden>
- Date: Mon, 17 Mar 2008 09:45:32 -0700
On Mar 17, 2008, at 7:15 AM, Fabrice Pipart wrote:
Hi !
I am sure this question has already been asked. But I looked in the
mailing list archives, in wiki books and in project wonder and could
not find any solution to a problem that should be... simple.
I have two entities Source and Dest with an optional many to many
relationship between them.
I want to fetch all the Source EOs that have no Dest EO in the many
to many relationship.
At first I tried :
String format = "(dests = nil)";
EOQualifier qual = EOQualifier.qualifierWithQualifierFormat(format,
new NSArray(new Object[] { }));
EOFetchSpecification fs = new EOFetchSpecification("Source", qual,
null);
No luck.
And the funniest part is that if you fetch with
String format = "NOT (dests = nil)";
and if among 10 objects you have 6 that correspond, you still have 0
using "(dests = nil)"
I think I understand why but the behavior is suprising.
ERXToManyQualifier should be a solution looking at its Javadoc.
I tried the following :
NSArray<Dest> a;
ERXToManyQualifier qual = new ERXToManyQualifier("dests", a);
EOFetchSpecification fs = new EOFetchSpecification("Source", qual,
null);
I get a null pointer exception because a is null.
I tried
NSArray<Dest> a = NSArray.emptyArray;
Still no luck, I get a SQL error because there is no element in the
Array.
Is it THAT complicated to fetch an EO with an empty to-many
relationship ???
Yes. That is the simple answer. For some reason, this was not
included in EOF. ExistsInRelationshipQualifier from the Houdah
Frameworks might do what you want.
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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