Re: search my EOModeled database using relationships.
Re: search my EOModeled database using relationships.
- Subject: Re: search my EOModeled database using relationships.
- From: Arturo PĂ©rez <email@hidden>
- Date: Mon, 6 Feb 2006 18:46:39 -0500
(Updated the subject to reflect the content.)
You'll be particularly interested in the EOQualifier classes, and the
EOUtilities filteredArray... and filterArray methods.
You'ld also probably be well served to add a method to your Company
class to encapsulate your particular filter logic and thusly may be
interested in using EOGenerator to create your Company.java.
Although, honestly, if the arrays are small you are perfecly
WO-compliant to loop through them yourself looking for
sellerCode.equals(aSellersCode).
-arturo
On Feb 6, 2006, at 6:15 PM, Scott Winn wrote:
Hello WO Gurus,
I need a good example of how to search my EOModeled database using
relationships. Both of the books I have purchased have remarkably
little to say on the subject. Here are the entities and their
relevant attributes. . .
Company
(PK) company_id
Relationship: Sellers (to Many)
Seller
(PK) seller_id
(FK) seller_company_id
seller_code
Relationship: Company (to One)
My code successfully gets a Company object from the database (referred
to as import_Company below). It also retrieves a String called
source_code to compare with the Seller object's seller_code to help
narrow the search.
What I want is essentially an object from Seller where
(seller_company_id == import_Company.company_id) and (seller_code ==
source_code)
I have looked high and low for an example of the "WebObjects Way" to
do this. Most all of the specific EOQualifier and FetchSpec examples
are about following a relationship to some value
employee.department.name etc. I was good and did NOT include Primary
or Foreign Keys accessors in my Java Class files.
I could do NSArray SellerArray = (NSArray)import_Company.Sellers();
and then search each array element for the source_code == seller_code
match I'm looking for, but there must be a better way. I have tried
to adapt some of the examples I managed to find, but naming
conventions were not good enough to help me figure out if they were
passing relationships or something else. I have tried
filteredArrayWithQualifier and objectMatchingValues with no success.
Thanks for bailing out the newbie,
Scott _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
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