• 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: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?


  • Subject: Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
  • From: Arturo Perez <email@hidden>
  • Date: Tue, 15 Mar 2005 14:26:42 -0500

Baiss Eric Magnusson wrote:

My problem with <addObjectToBothSidesOfRelationshipWithKey>, throughout the ages, and I do mean years, is that when the <ec.saveChanges()> occurs the primary keys are assigned and when you are trying to work with 2 related objects simultaneously the relationship fails because the DB hasn't assigned the primary key for the 2nd object. The primary keys are always assigned at ec.saveChanges() time and no other time. I can't seem to get the staging correct.

I've never run into this problem and I'm very relationship happy in my eomodels. The most I've needed to do to get things to work is to set constraints as DEFERRED. For example, one of my entities is a 5-way join table with attributes. I dutifully create all 6 entities, hook them up with addObject<..> and it works every time. I wonder what's so different in your case?



So I get:
Next exception:SQL State:23 -- error code: 359 -- msg: Exception condition 359. Integrity constraint violation (NULL in PRIMARY KEY, TASK._C0000000034(EVENT_ID=NULL)).

Are your primary keys class properties? In my models I never set primary keys and I therefore never have them exposed.


Sheepishly I have always hacked it by first doing a ec.saveChanges() on the parent and then a ec.saveChanges() on the child, a terribly annoying hack.



The code I've sent you has never failed me. I don't even subclass EOEditingContexts or anything like that.


_______________________________________________ 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: 
 >Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right? (From: Baiss Eric Magnusson <email@hidden>)
 >Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right? (From: Arturo PĂ©rez <email@hidden>)
 >Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right? (From: Baiss Eric Magnusson <email@hidden>)

  • Prev by Date: Re: WOTextField Validation Messages
  • Next by Date: Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
  • Previous by thread: Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
  • Next by thread: Re: Why can't I get <addObjectToBothSidesOfRelationshipWithKey> right?
  • Index(es):
    • Date
    • Thread