Re: "one to meny" as "one to one"
Re: "one to meny" as "one to one"
- Subject: Re: "one to meny" as "one to one"
- From: Nathan Dumar <email@hidden>
- Date: Thu, 12 Aug 2004 14:06:09 -0400
Sako,
You could prefetch the relationship of customer to orders, which would
get all of the previous orders at the same time as the customer fetch.
Before displaying, sort descending by date and show only the first
record. Maybe there's a way to put a fetch limit on a relationship
prefetch?
Better yet, if you can modify your data structure, add another field to
the customer, which would be something like lastOrder, and would be a
to-one relationship to the order table. Every time you create a new
order, change the relationship customer.lastOrder to the new order.
This can be done automatically by putting the change relationship code
in the order class (if you need more explanation here, just ask).
Then, when you fetch the customer, you automatically get the last
order. Funny, I just did this a few days ago.
Nathan
On Aug 12, 2004, at 11:34 AM, Sako! wrote:
hello,
i have table costemers. includes name column
i have talbe orders. includes date order
i would like to read costerms who start thier name with 'xxx' and i
want to read in the same time thier last order date.
in simple model i will get something like this.
---------------------------
nr name date
1 sako 1.1.2004
2 sako 1.2.2004
3 sako 1.3.2004
4 man 5.3.2004
5 man 1.2.2004
---------------------------
what i want to have is :
---------------------------
nr name date
1 sako 1.3.2004
2 man 5.3.2004
---------------------------
i mean for each user one row including the date of the last order. i
have ofcourse the proper PKs and FKs.
can i do that at all in one fetch?
regards.
sako.
_______________________________________________
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.