FAQ
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.validateAndCheckNoop(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.

Search Discussions

  • Andrus Adamchik at Aug 7, 2006 at 2:51 pm
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedAug 7, '06 at 2:37p
activeAug 7, '06 at 2:51p
posts2
users2
websitecayenne.apache.org

2 users in discussion

Andrus Adamchik: 1 post Bryan Lewis: 1 post

People

Translate

site design / logo © 2022 Grokbase