Whats the recommended way for cross-object information inquiry?
Whats the recommended way for cross-object information inquiry?
- Subject: Whats the recommended way for cross-object information inquiry?
- From: Magnus Rembold <email@hidden>
- Date: Tue, 9 Mar 2004 21:46:40 +0100
Dear List,
since I am still new to WO, I am wondering a lot about the
"recommended" way for doing things. And this is where code examples
seem to fail for me. Lots of people say "read the example code" but
this approach almost always lacks the "Why?"s and you don't get a feel
for how the best solution for the design would be and why. All you get
is: it's working this way. Not: this is the most elegant way to do it
and besides it goes nicely with the design of WO.
--- Problem:
I've got a bunch of objects with relations. Now I want to present a
kind of semi-deep list into the top objects and their relations where
the relations meet a certain criteria. Suppose the top objects
represent households, the related objects are persons and I want to
select only those that are born in a certain year. Suppose there are
not a lot of objects, so I want to specify a list of selectable years,
since not every year has a result and I want the user to always get a
result.
What I want to do is, get through all the persons and compile a list of
birthdates that are selectable as search criteria. So, how to do it?
My knowledge of WO from my reading so far would tell me: Fetch all
households, repeat through them, repeat through their persons, take
each birthdate and put it in a list if it is not already there. That
means, WO has to load nearly all the objects from the DB
My knowledge of my DB tables would lead me to a simple SQL statement
like SELECT YEAR, count(*) FROM PERSONS_TABLE GROUP BY YEAR ORDER BY
YEAR; I only had to figure out how to do a raw SQL statement and get
the values in an NSArray so I can use a WORepetition. But this leaves
me with table-dependent knowledge inside my Java source code.
Now... what is the recommended way of doing this? Object traversal and
compiling the list for yourself or raw SQL and converting the results?
Or is there a third much more WO-design-like manner for solving this?
Your comments, hints and help are very welcome. As always. ;-)
Best regards,
Magnus
________________________________________________________________________
__________
Magnus Rembold HOCHSCHULE F\R GESTALTUNG UND KUNST Z\RICH
Dozent IT-Technologien University of Applied Sciences and Arts Zurich
School of Art and Design Zurich
Fon +41 43 446 3256
Fax +41 43 446 4587 Ausstellungsstrasse 60
http://interaction.hgkz.ch CH-8031 Z|rich
_______________________________________________
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.