openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiaoqin Feng (JIRA)" <j...@apache.org>
Subject [jira] Updated: (OPENJPA-635) child record foreign key column set to null on deletion of parent record even foreign key delete action is set to "restrict"
Date Thu, 10 Jul 2008 19:12:31 GMT

     [ https://issues.apache.org/jira/browse/OPENJPA-635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Xiaoqin Feng updated OPENJPA-635:
---------------------------------

    Attachment: openjpa-635.patch

proposed patch to solve this problem.

> child record foreign key column set to null on deletion of parent record even foreign
key delete action is set to "restrict"
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-635
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-635
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.1.0
>         Environment: Windows
>            Reporter: Xiaoqin Feng
>            Priority: Trivial
>         Attachments: openjpa-635.patch
>
>
> When using an inverse key collection mapping, if you delete the parent 
> object, the FK column of the corresponding child record(s) are set to null. 
> If there is a null constraint on the column (as is normally the case in a FK 
> column), this will result in a null constraint error.  But we expect to get FK constraint
error.
> For example,
>     @ManyToOne(optional=false)
>     @JoinColumn(name="PARENT_ID", nullable=false)
>     @ForeignKey
>     private OneManyParent parent;
> If we set  "nullable=false" in JoinColumn,  then it throws FK constraint exception as
expected.
> But since the default deleteAction value for  "ForeignKey" annotation is "restrict",
even "nullable=false" is not set, it should behave as "restrict".
> Note: for "Column" and "JoinColumn", the default value is "nullable=true".
> I checked RelationToManyInverseKeyFieldStrategy.delete(), ForeignKey deleteAction is
not evaluated at all. It only check if Column is nullable.
> I will try to attach test case soon.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message