Chuck Hill wrote on 12/14/05 9:29 PM:
On Dec 14, 2005, at 6:20 PM, Arturo Pérez wrote:
Zak Burke wrote:
[EMAIL PROTECTED] wrote on 12/13/05 3:57 PM:
In my experience, WO will update attributes persisted to the DB, but for relations it only pulls from its cache.

AFAIK, That's only true if you don't use EOF to make the relationship changes (think trigger or such) OR your code is wrong.

-arturo

P.S.  I am willing to concede that I may be wrong about this.


Settle for kinda half wrong sometimes?  :-P

I think what Zak may be thinking of is to-many relationships.... EOF
caches _which_ objects are in the relationship and that does not get refreshed when one might expect that it would.

Chuck

Yes, it's to-many relationships that are constantly beguiling me. In the specific example I had in mind here, I was working with a tree-based structure that had DirectAction links for adding new nodes anywhere on the tree. Submitting the DA page reloaded the (also DA-based) tree-display page. Node changes would show up in my DB, but I until I set the relationships to prefetch I never saw them on my page.

It may also be that I'm fundamentally abusing some core aspect of the frameworks or have missed some subtlety of the RR loop, though I think I'm past the simple mistakes like fetching in the constructor. So it may be that all these problems are in my own framework, or my own mindset if I'm not thinking according to the Tao of Apple.

After bashing my head against this problem for a while, I found that I could always get the results from the DB if I always explicitly prefetch to-many relations. This may not be an elegant solution, but it works, and now I can worry about other WO gotchas.

(Like, for example, if you use Generation Gap and override super.getList() in the derived class so you can sort it. You better call super.setList(sortedList) in the derived class's getList() method if you want to make any changes to those items. NSArray.sortedArrayUsingComparator returns a new list, and the items on it apparently don't equal() the items on the original list. I dunno why, but they don't. If you edit an item on the sorted list and then save it, the results are funky and unpredictable. Random relationships are nullified, others are preserved just fine. That was a fun one.)

zak.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to