On Dec 4, 2009, at 8:02 AM, Ramsey Lee Gurley wrote: > Hi Kieran, > > Have you tried vertical inheritance with MySQL? I have Animal->Cat->Leopard. > I try to create a leopard and it fails because > > com.webobjects.eoaccess.EOGeneralAdaptorException: EvaluateExpression failed: > <com.webobjects.jdbcadaptor._MySQLPlugIn$MySQLExpression: "INSERT INTO > Leopard(spots, id) VALUES (?, ?)" withBindings: 1:33(spots), 2:9(id)>: > Next exception:SQL State:23000 -- error code: 1452 -- msg: Cannot add or > update a child row: a foreign key constraint fails (`example/leopard`, > CONSTRAINT `Leopard_id_id_FK` FOREIGN KEY (`id`) REFERENCES `cat` (`id`)) > > It gets the adaptor operations for Animal, then Leopard, then Cat... and > blows up at leopard because there's no cat yet (I think).
That's exactly the problem. The easiest way avoid this is by not having FK constraints in the DB at all (which is what Kieran is saying he does - you could think of this as infinitely-deferred constraints). But wait, it gets worse. Here's the _really_ frustrating part: EOF doesn't always do things in the same order, so you could set things up with FK constraints and have it all work just fine for weeks or months with only the occasional error, and then have it suddenly start failing every time. > I had to google for "What are deferred constraints" so I could be very wrong, > but I think it's blowing up because of lack of deferred constraints (^_^) It > looks like I'll need to have an EODatabaseContext delegate override > databaseContextWillOrderAdaptorOperations to fix it, unless there is > something in the ERXSQLHelper that can get there first. Or you can just not use Vertical Inheritance. :-) Dave _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com