cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Rigby-Jones (Created) (JIRA)" <>
Subject [jira] [Created] (CAY-1636) NPE with commitChangesToParent() after deleting object with child and cascade delete rule
Date Tue, 01 Nov 2011 17:21:32 GMT
NPE with commitChangesToParent() after deleting object with child and cascade delete rule 

                 Key: CAY-1636
             Project: Cayenne
          Issue Type: Bug
          Components: Core Library
    Affects Versions: 3.0.2
            Reporter: Mark Rigby-Jones

Steps to reproduce:

1) Create object A
2) Add child object B (A has a cascade delete rule for B)
3) Create a child context
4) Delete A in the child context
5) commitChangesToParent in the child context
6) NPE:
	at org.apache.cayenne.access.DataContextDeleteAction.performDelete(
	at org.apache.cayenne.access.DataContext.deleteObject(
	at org.apache.cayenne.graph.ChildDiffLoader.nodeRemoved(
	at org.apache.cayenne.graph.NodeDeleteOperation.apply(
	at org.apache.cayenne.graph.CompoundDiff.apply(
	at org.apache.cayenne.access.ObjectStoreGraphDiff.apply(
	at org.apache.cayenne.access.DataContext.onContextFlush(
	at org.apache.cayenne.BaseContext.onSync(
	at org.apache.cayenne.access.DataContext.flushToParent(
	at org.apache.cayenne.access.DataContext.commitChangesToParent(


The issue appears to be that the graph diff to be committed to the parent context records
that both A and B are to be deleted, however the delete rules for A also cause B to deleted:

1) Child diff causes A to be deleted
2) A's delete rules cause B to deleted
3) Child diff causes B to be deleted, but B no longer exists

Possible fix (not tested in any way):

In ChildDiffLoader.nodeRemoved(), check if the result of findObject() is null before attempting
to delete it.

Workaround (works for me):

In the child context, delete B before deleting A.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message