openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick (JIRA)" <>
Subject [jira] Resolved: (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 Tue, 22 Feb 2011 02:40:38 GMT


Michael Dick resolved OPENJPA-635.

    Resolution: Cannot Reproduce

The latest versions of OpenJPA handle this case before the SQL goes to the database.

You'll see something like this instead : 
<openjpa-2.2.0-SNAPSHOT-r422266:1073201M fatal user error> org.apache.openjpa.persistence.InvalidStateException:
The field "parent" of instance "org.apache.openjpa.persistence.relations.CascadingOneManyChild@6c89db9a"
contained a null value; the metadata for this field specifies that nulls are illegal.
	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
	at org.apache.openjpa.kernel.SingleFieldManager.preFlush(
	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(
	at org.apache.openjpa.kernel.PNewState.beforeFlush(

I'm resolving the issue as cannot reproduce - since the original problem only occurred with
Kodo. If there's another use case for the patch, please reopen. 

> 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:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.1.0
>         Environment: Windows
>            Reporter: Xiaoqin Feng
>            Assignee: Michael Dick
>            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
> 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
> 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.
For more information on JIRA, see:


View raw message