cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Durchholz, Joachim" <Joachim.Durchh...@hennig-fahrzeugteile.de>
Subject RE: Recursive FK constraints in MySql
Date Mon, 26 Sep 2011 09:12:05 GMT
> I want to delete a row from a particular table. Unfortunately
> the table in question has a FK constraint to another table,
> which in turn has a FK constraint back to the table in question.
> Even the latest version of MySql (I tried 5.5) does constraint
> checking on a per-statement rather than per-transaction basis.
> Basically the constraints are always tripped and the only way
> I've found to allow the delete to proceed is to drop the FK
> constraints.

You could set a field to NULL first, breaking the cycle in the data.
That way, you get a record that you can delete, and unravel the FK chain from there.
As said in the thread you linked, Cayenne might sabotage you by reordering actions, so you
might want to work around that by dropping down to raw SQL or by committing after each step.

I don't know why disabling FK checking doesn't work for you.
But then we don't know what errors you got from that attempt, so it's a bit hard to guess
what might be wrong with your code.

Regards,
Jo

Mime
View raw message