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 ???
Best regards
Fabrice Pipart
EasyMediaOnline Digital Signage Software
Easyshadow Palais de la Scala 1 avenue Henri Dunant Suite 1155 MC - 98000 Monaco
Skype: fabrice.pipart Tel. +377 97 98 21 04 (direct) Fax. +377 97 70 88 07
|