Probably should be the other way around - toOne relationship with "nullify" and complimentary "toMany" with cascade. It is essentially a question of which side of the relationship can exist independently from another side, and which one can not.

Andrus

On Aug 7, 2006, at 10:37 AM, Bryan Lewis wrote:

I have this code that deletes a list of calendar records for a
deactivated employee:

    Expression nameExp = ExpressionFactory.matchExp("name", name);
    SelectQuery query = new SelectQuery(Calendar.class, nameExp);
    List items = dc.performQuery(query);
    for (ListIterator it = items.listIterator(); it.hasNext(); ) {
        Calendar item = (Calendar) it.next();
        it.remove();
       dc.deleteObject(item);
    }

It worked fine until I added a Nullify delete rule to the Calendar
entity, on a reverse to-many relationship from Calendar to itself. Now
when the commitChanges() happens after the above deletion code, I get:

 java.util.ConcurrentModificationException
 java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
 java.util.HashMap$EntryIterator.next(HashMap.java:829)
 java.util.HashMap$EntryIterator.next(HashMap.java:827)
org.objectstyle.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNo op(ObjectStoreGraphDiff.java:109) org.objectstyle.cayenne.access.DataContext.flushToParent (DataContext.java:1244) org.objectstyle.cayenne.access.DataContext.commitChanges (DataContext.java:1165)

Should I be doing this some other way?  This is with version 1.2.

Reply via email to