openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "roger.keays" <roger.ke...@ninthavenue.com.au>
Subject deferring fk constraints problem
Date Fri, 17 Nov 2006 07:37:16 GMT

Okay, so I'm a bit of a referential integrity fanatic.

There may be a problem where the order of deletes causes fk constraint
exceptions in certain cascade delete operations. The conditions for this
are:

    * 1-1 forward mapped relationship
    * relationship marked <cascade-delete/>
    * fk action is 'restrict' (fk is in owner's table)
    * database does not support deferred constraints

<cascade-delete/> tries to delete the owned object first, but the owner must
be deleted first since the constraint is non-deferrable. There is no problem
in inverse-mapped relationships because the fk is in the owned table, not
the owner's.

Am I making sense?

The problem is worked around by making the fk SET NULL instead of RESTRICT,
but that isn't necessarily always what you want. 

It might also be useful to provide different fk configuration options for
forward and reversed mapped fk's (i.e. ForeignKeyDeleteAction,
InverseForeignKeyDeleteAction).

Roger
-- 
View this message in context: http://www.nabble.com/deferring-fk-constraints-problem-tf2649997.html#a7395124
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Mime
View raw message