Newbie: Many to Many, EOAndQualifier
Newbie: Many to Many, EOAndQualifier
- Subject: Newbie: Many to Many, EOAndQualifier
- From: Benjamin Miller <email@hidden>
- Date: Tue, 6 May 2003 16:03:06 +0100
I have two entities:
Creation, which has a flattened many to many array of Tool entities
called 'tools'.
Tools, has attributes 'category' and 'tool'.
I want to fetch Creations from Openbase using an EOFetchSpecification
with an EOAndQualifier that uses tools.tool as the attribute to search
for.
NSMutableArray qualifiers = new NSMutableArray();
qualifiers.addObject(EOQualifier.qualifierWithQualifierFormat("tools.too
l = '90mm'", null));
qualifiers.addObject(EOQualifier.qualifierWithQualifierFormat("tools.too
l = 'Gandolfi Field Camera'", null));
EOAndQualifier comboQualifier = new EOAndQualifier(qualifiers);
When using just one source EOQualifier everything works fine, but when
using two or more source qualifiers no Creation entities are returned
from the fetch spec.
Having looked at the SQL -
<com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "SELECT
DISTINCT t0.AVAILABLE_DATE, t0.COPY, t0.COUNTRY, t0.CREATION_DATE,
t0.CREATION_FOCUS, t0.CREATION_MATERIAL, t0.CREATION_SERIES,
t0.CREATOR_ID, t0.EDITOR, t0._timestamp, t0.LEARNING_RESOURCE,
t0.NOTES, t0.ORIGINAL_URL, t0.PUBLIC_POSTCARD, t0.PUBLIC_SCREENSAVER,
t0.PUBLIC_SLIDESHOW, t0.PUBLIC_WALLPAPER, t0.REGION, t0._rowid,
t0.RUNNING_TIME, t0.SELECTOR, t0.SHORT_COPY, t0.SITES, t0.SYNOPSIS,
t0.TITLE, t0.TYPE FROM CREATION t0, K_TOOL T2, J_CREATION_TOOL T1 WHERE
(T2.TOOL = ? AND T2.TOOL = ?) AND T1.TOOL_ID = T2._rowid AND t0._rowid
= T1.CREATION_ID" withBindings: 1:"90mm"(tool), 2:"Gandolfi Field
Camera"(tool)>
[2003-05-06 15:34:19 BST] <WorkerThread0> 0 row(s) processed
- it looks as if the fetch spec is looking for one Tool that contains
both search terms rather than selecting Creations that have a Tool
(named "90mm") and a different Tool (named "Gandolfi Field Camera").
I would like to know is there an accepted method (or any method) for
creating fetches than can retrieve different objects of the same type
from many to many relationships? This works with quite a few other
attributes and relationships
(
http://www.dshed.net/cgi-bin/WebObjects/Digitised.woa/wa/advancedSearch
)
so I didn't want to change things too much. Ideally, I would like to
still generate an EOAndQualifier from an array of EOQualifiers. Does
this type of search require more than one fetch from the database with
filtering in memory of the combined fetches?
thanks, Benjamin
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.