• 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: Save order of EO objects to support database foreign key constraints.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Save order of EO objects to support database foreign key constraints.


  • Subject: Re: Save order of EO objects to support database foreign key constraints.
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 25 May 2017 16:15:28 +0000
  • Thread-topic: Save order of EO objects to support database foreign key constraints.

That is in Wonder now, IIRC.

 

The other thing to do, if you database supports it, is to mark the constraints as DEFERRABLE INITIALLY DEFERRED.  The delegate was intended to handle the cases where the database did not support that.

 

Chuck

 

 

From: Webobjects-dev <webobjects-dev-bounces+chill=email@hidden> on behalf of Aaron Rosenzweig <email@hidden>
Date: Thursday, May 25, 2017 at 8:32 AM
To: Steve Peery <email@hidden>
Cc: WebObjects Development <email@hidden>
Subject: Re: Save order of EO objects to support database foreign key constraints.

 

Hi Steve,

 

You can make a delegate to handle the ordering of database operations.

 

Chuck Hill made one that might just work for you but if you need something additionally custom you’ll have to take over.

https://lists.apple.com/archives/webobjects-dev/2007/Jun/msg00751.html

 

Aaron Rosenzweig / Chat 'n Bike
e:  email@hidden  t:  (301) 956-2319

mage removed by sender. Chat 'n Bike

mage removed by sender. Chat 'n Bike

 

On May 25, 2017, at 10:54 AM, Steve Peery <email@hidden> wrote:

 

Hey List,

I am importing a bunch of relational data into a project and when I try to save changes I get an error something like this:

Error when attempting to save data: EvaluateExpression failed: : Next exception:SQL State:23000 -- error code: 1452 -- msg: Cannot add or update a child row: a foreign key constraint fails (`valueA`.`valueB`, CONSTRAINT `TableA_tableBID_id_FK` FOREIGN KEY (`tableBID`) REFERENCES `tableB` (`id`))

I know it is because they are not written to the database in the order created. I have dealt with this in the past by doing incremental saving and other awkward things, but in this case that would be a total pain.

Any suggestions for the best way to deal with this?

Thank you,

Steve Peery
_______________________________________________
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

 

 _______________________________________________
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

  • Follow-Ups:
    • Re: Save order of EO objects to support database foreign key constraints.
      • From: Steve Peery <email@hidden>
References: 
 >Save order of EO objects to support database foreign key constraints. (From: Steve Peery <email@hidden>)
 >Re: Save order of EO objects to support database foreign key constraints. (From: Aaron Rosenzweig <email@hidden>)

  • Prev by Date: Re: Save order of EO objects to support database foreign key constraints.
  • Next by Date: Re: Save order of EO objects to support database foreign key constraints.
  • Previous by thread: Re: Save order of EO objects to support database foreign key constraints.
  • Next by thread: Re: Save order of EO objects to support database foreign key constraints.
  • Index(es):
    • Date
    • Thread