On Dec 22, 2010, at 10:30 AM, Ramsey Gurley wrote:

> MySQL does not have deferred fk constraints.  EOF doesn't order operations, 
> it just commits en masse.  So, if you want to use fk constraints with MySQL, 
> you have to order the operations yourself.  There is some magic in wonder for 
> this
> 
> http://lists.apple.com/archives/Webobjects-dev/2007/Jun/msg00751.html
> 
> However, keep in mind that required, circular relationships cannot be modeled 
> in MySQL if you use FK constraints.  If the relationship is circular, no 
> amount of operation ordering will fix your problem AFAIK.

You could possibly order by the PK/FK if the relationship was A->B->C in the 
same table.  If it is A<->B, then that is not possible.


> Or you can just turn off constraints and live dangerously... or switch to 
> Postgres.  It's free and has deferred FK constraints. Or Frontbase.... or if 
> you're made out of money, Oracle...  I even read SQLite has deferred FKs... 
> cool! (^_^)

Microsoft SQL Server does not support deferred constraints either, so MySQL is 
in good company!  :-P


Chuck


> On Dec 22, 2010, at 1:13 PM, Jesse Tayler wrote:
> 
>> Hi Paul
>> 
>> thanks for your reply -- but
>> 
>> How do you mean?
>> 
>> I establish other foreign keys on other tables without troubles? Their SQL 
>> runs. this line is my only trouble - I thought it was mismatched "id" types 
>> for some reason, but you think the trouble is in my model somewhere?
>> 
>> 
>> 
>> 
>> On Dec 22, 2010, at 12:54 PM, Paul D Yu wrote:
>> 
>>> Jesse
>>> 
>>> I believe foreignKeys do not work on MySQL with EOF.
>>> 
>>> Paul
>>> On Dec 22, 2010, at 12:53 PM, Jesse Tayler wrote:
>>> 
>>>> I've had ERAttachment tests working once or twice, now I think maybe I've 
>>>> gotten models confused somewhere perhaps.
>>>> 
>>>> I have a poster relationship from user which eogen's a line to add a 
>>>> foreign key, which I think should be there, but this step fails - in past 
>>>> experience, this has been mismatched id key types, but I don't see that 
>>>> here.
>>>> 
>>>> Everything is setup with "id" as a prototype for mysql.
>>>> 
>>>> I see some similar troubles with Postgres on the list or google, but I'm 
>>>> on Mysql and just starting a new dev. environment etc.
>>>> 
>>>> This foreign key should be there right? Any ideas why it might be failing?
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>            userTable.addForeignKey("posterId", "ERAttachment", "id");
>>>> 
>>>> Can't create table 'mtly.#sql-731_26c3' (errno: 150)
>>>> 
>>>> Failed to execute 'ALTER TABLE USER ADD CONSTRAINT 
>>>> USER_posterId_posterId_FK FOREIGN KEY (posterId) REFERENCES ERAttachment 
>>>> (id)'.
>>>> 
>>>> 
>>>> 
>>>> 
>>>> If I ignore, I'll get a runtime:
>>>> 
>>>> 
>>>> 
>>>> 
>>>> com.webobjects.eoaccess.EOGeneralAdaptorException: EvaluateExpression 
>>>> failed: : Next exception:SQL State:23000 -- error code: 1452 -- msg: 
>>>> Cannot add or update a child row: a foreign key constraint fails 
>>>> (`mtly`.`ERAttachment`, CONSTRAINT 
>>>> `ERAttachment_attachmentDataID_attachmentDataID_FK` FOREIGN KEY 
>>>> (`attachmentDataID`) REFERENCES `ERAttachmentData` (`id`))
>>>> 
>>>> Reason:
>>>> 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:73207(size), 2:2(attachmentDataID), 3:true(available), 4:2010-12-21 
>>>> 22:23:33(creationDate), 5:"image/jpeg"(mimeType), 
>>>> 6:"jesseheadshot.jpg"(originalFileName), 7:"/2.jpg"(webPath), 8:2(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 (`mtly`.`ERAttachment`, CONSTRAINT 
>>>> `ERAttachment_attachmentDataID_attachmentDataID_FK` FOREIGN KEY 
>>>> (`attachmentDataID`) REFERENCES `ERAttachmentData` (`id`))
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list      ([email protected])
>>>> Help/Unsubscribe/Update your Subscription:
>>>> http://lists.apple.com/mailman/options/webobjects-dev/pyu%40mac.com
>>>> 
>>>> This email sent to [email protected]
>>> 
>>> 
>> 
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/webobjects-dev/ramsey%40xeotech.com
>> 
>> This email sent to [email protected]
>> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
> 
> This email sent to [email protected]

-- 
Chuck Hill             Senior Consultant / VP Development

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







Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to