• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I update a relationship in a WODisplayGroup?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I update a relationship in a WODisplayGroup?


  • Subject: Re: How do I update a relationship in a WODisplayGroup?
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 15 Dec 2005 09:56:02 -0800

Hi Zak,

On Dec 15, 2005, at 6:16 AM, Zak Burke wrote:

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@hidden 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.


In that case, I agree with Arturo - it's your code. :-) The problem that I described should only happen if you are running multiple instances. It should not occur when developing (which makes it so much fun to find and fix. It will happen during development if you are creating multiple EOF stacks (new EOEditngContext(new EOObjectStoreCoordinator()) ) but it does not sound like you are doing that.


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.

It sounds to me like one of these is true:
1. You are using addTo... or set... instead of addObjectToBothSidesOfRelationshipWithKey and only half of the EOF relationship is getting updated
2. You have a problem in your model, either missing or incorrectly modeled relationships
3. You are directly manipulating the primary and foreign keys (shudder)




(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.)

This is your bad. You should not change the behavior of generated methods. I would create an orderedList() method and sort and return list() from that. EOF uses, and depends on, these methods. Change how they work and you mess with EOF's head. Then it messes with yours. ;-)

And, BTW, if you check the JavaDocs for NSArray it says, "Two arrays have equal contents if they each hold the same number of objects and objects at corresponding indices in each array satisfy the equals test.". So, yes, an array and a sorted version of that array are not equal. Arrays are ordered lists and order counts.

Chuck

--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro


Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects




_______________________________________________ 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
References: 
 >Fwd: How do I update a relationship in a WODisplayGroup? (From: Arturo Pérez <email@hidden>)
 >Re: How do I update a relationship in a WODisplayGroup? (From: Chuck Hill <email@hidden>)
 >Re: How do I update a relationship in a WODisplayGroup? (From: Zak Burke <email@hidden>)

  • Prev by Date: Re: How do I update a relationship in a WODisplayGroup?
  • Next by Date: Direct printing with JIPSI [Was : Re: printing]
  • Previous by thread: Re: How do I update a relationship in a WODisplayGroup?
  • Next by thread: stringQualifierOperators (like, contains)
  • Index(es):
    • Date
    • Thread