Ondra,

In this case, I would use EOSQLQualifier.  Something like:

exists (select 1 from reltable where t0.primaryKey = reltable.foreignKey)

Using t0 assumes standard EOF SQL generation and the target table should be the target of the query (not a relationship from something else).

You can then mix the EOSQLQualifier in with other qualifiers to further qualify the result if necessary.

Ken

On Feb 17, 2006, at 5:05 PM, Ondra Cada wrote:

Hello,

this, I am afraid, is kind of EOF 101; still I haven't been able to find the answer on wodeveloper... thus, please, forgive the following question.

I need an efficient qualifier to fetch all objects from entity A, whose to-many relationship to another entity is non-empty (i.e., there is at least one object in the relationship). A programming solution like

  NSMutableArray *ma=[NSMutableArray array];
for (id o,en=[[editingContext objectsForEntityNamed:@"A"] objectEnumerator];o=[en nextObject];)
    if ([[o theRelationship] count]>0) [ma addObject:o];

is, with the number of objects, out of question for it is too inefficient.

Although from easthetical reasons I would like to use as high API level as possible, in worst, in this project it might be an EOSQLQualifier and the SQL might be MS-SQL-tailored, or even rawRowsWithSQL:modelNamed:. Alas, I am no SQL guru, and don't know how to create appropriate SQL expression.

Since the project is WO4.5-based, the ERXToManyQualifier of Project Wonder does not really help (unless I get all the sources and turn them to Objective-C myself).

Grateful for any help,
---
Ondra Čada
OCSoftware:     [EMAIL PROTECTED]               http://www.ocs.cz
private         [EMAIL PROTECTED]             http://www.ocs.cz/oc


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/lists% 40anderhome.com

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to