wacky EOF prefetching and flattened relationships
wacky EOF prefetching and flattened relationships
- Subject: wacky EOF prefetching and flattened relationships
- From: Zak Burke <email@hidden>
- Date: Mon, 03 Oct 2005 19:34:36 -0400
This is a long story, and I've resolved the problem, but I'm hoping
somebody who understands EOF better than I can explain why I encountered
the problem in the first place.
Here is the setup: I have two classes (Meeting, Person) in a to-many
relationship through a join table. Meeting also has a flattened
relationship pointing back to Person. I have a DirectAction page that
lists the people who attend meetings, and another page that allows
meeting attendees to be changed. The view page fetches all its objects
in appendToResponse and its fetches use setRefreshesRefetchedObjects(true).
Here is where things get strange.
Once the view page had been loaded once, additions from the edit page
would not be reflected on the view page. Logging out the SQL showed that
the meeting and all the people were being retrieved on each request. For
example, the SQL log would show, "5 row(s) processed" but
meetingItem.people.count() would return 4. Somehow, even though the
meeting and its related items were being refetched, the count of its
related items was being pulled from a cache.
Similarly, removing attendees from the edit page would cause the view
page to bomb. We tried a list enumeration and a for loop, but both threw
classcast exceptions (not ArrayOutOfBoundsExceptions). For example, the
SQL log would show, "5 row(s) processed" but meetingItem.people.count()
would return 6.
Question 1: Since the meeting and its attendee list are being refetched
on every request, why oh why is the meeting-person relationship being
cached?
I decided to try prefetching the meeting-person relationship to see if
that would fix the problem. For reasons I don't remember, I only set the
flattened relationship to be prefetched, but I logged out the count of
both the join and the flattened relationships.
Here is where things get really strange.
After making an attendance change, the flattened relationship would
report the updated count but the relationship on the join table would
report the old, incorrect count.
Question 2: Huh? The flattened relationship is defined *in terms of* the
join table relationship. How is it possible for the flattened
relationship to show an updated count if the relationship it depends on
is not updated?
Prefetching the join relationship fixed the problem, so this is all
moot, but I don't like closing bugs when I don't understand what the
problem was, or why the solution solved it.
Thanks for any insights,
zak.
p.s. Extra credit to the person who can explain why this problem showed
up on both our MacOS 10.3.9 Server machines, not on our 10.3.9 Client
machines (2 of those, too). The machines are otherwise identical: Apache
1.3.33, WO 5.2.3, MySQL 4.1.7.
_______________________________________________
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