Reading a couple of posts on this topic, I'm unclear what I should be doing when removing items from the "Many" side of my CMR (JBOSS 4.0.0)
My code (pseudocode) reads like this:
Collection children = parent.getChildren();
Iterator childIterator = children.iterator();
MyChild child = (MyChild)childIterator.next();
System.out.println("Num children: " + children.size());
System.out.println("Num children: " + parent.getChildren().size());
The issue is, the two println() calls output what I expect (they reflect that I removed some children). But when I commit the transaction and look in my DB, the records haven't been removed and when I start a new transaction, they are resurrected when I do my call to getChildren();
I tried adding a child.remove() but that modifies the underlying Collection and my next call to next() on my Iterator failes with an IllegalStateException because of the modification to the underlying Collection.
Should I expect that a call to setChildren() should remove() records from the database for any children that are no longer in the Collection?