My guess is that the order of save operations means that sometimes you are not violating the foreign constraint and other times you are. Bottom line, MySQL does not support DEFERRED Foreign Key Constraints, so the easy fix is to eliminate Foreign Key constraints in the database if you use MySQL unfortunately. You can still set FK fields NOT NULL in the DB (of course you must set STRICT_SQL mode to prevent INT(11) NOT NULL; silently turning into INT(11) NOT NULL DEFAULT '0'; ...... details, details :) )
On Sep 10, 2012, at 3:43 AM, Ângelo Andrade Cirino <aacir...@gmail.com> wrote: > Hi, > > As I said in a previous post, I have two applications using the same > framework. In one of them I am able to use ERAttachments to add an image to > an entity. But in the other application, trying to attach an image to an > entirely different entity, I have the following: > > EOGeneralAdaptorException: EvaluateExpression failed: > <com.webobjects.jdbcadaptor._MySQLPlugIn$MySQLExpression: "INSERT INTO > ERAttachment(size, width, height, attachmentDataID, available, thumbnail, > creationDate, ownerID, configurationName, smallData, mimeType, > originalFileName, webPath, id, proxied, storageType) VALUES (?, NULL, NULL, > ?, ?, NULL, ?, NULL, NULL, NULL, ?, ?, ?, ?, ?, ?)" withBindings: > 1:18160(size), 2:2(attachmentDataID), 3:true(available), 4:2012-09-10 > 04:16:43(creationDate), 5:"image/jpeg"(mimeType), > 6:"miniatura.jpg"(originalFileName), 7:"/1.jpg"(webPath), 8:1(id), > 9:true(proxied), 10:"db"(storageType)>: > Next exception:SQL State:23000 -- error code: 1452 -- msg: Cannot add or > update a child row: a foreign key constraint fails > (`visionturtestes`.`erattachment`, CONSTRAINT > `ERAttachment_attachmentDataID_id_FK` FOREIGN KEY (`attachmentDataID`) > REFERENCES `ERAttachmentData` (`id`)) > at > com.webobjects.eoaccess.EODatabaseContext._exceptionWithDatabaseContextInformationAdded(EODatabaseContext.java:4504) > > The two applications are running simultaneously and I am updating one > different entity in each one. Why does the same function present two > different behaviours? > > BTW, the ERAttachment used to work perfectly in the troubled application. > > BTW 2: rule files that used to be loaded aren't being loaded anymore. > > BTW 3: if I clean the models framework and the applications and rebuild them > the error above is gone, for a while... > > Angelo > _______________________________________________ > 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: > https://lists.apple.com/mailman/options/webobjects-dev/kelleherk%40gmail.com > > This email sent to kelleh...@gmail.com
_______________________________________________ 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: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com