-
1. Re: CMP ejbRemove(): Underlying collection has been modified
sergeibatiuk Jul 27, 2002 7:58 AM (in response to sergeibatiuk)There has been a mistake in my previous message:
my ejbRemove() method, that doesn't work (but should work in my opinion):
---------------------------------
public void ejbRemove() {
Iterator children = getChildren().iterator();
while ( children.hasNext() ) ( ( TreeNode )children.next() ).remove();
}
ejbRemove() that works, but requires addition ejbSelect() method:
---------------------------------
public void ejbRemove() {
Iterator children = ejbSelectChildren( ( TreeNode ) entityContext.getEJBLocalObject() ).iterator();
while ( children.hasNext() ) ( ( TreeNode )children.next() ).remove();
}
---------------------------------
All this wouldn't be an issue if cascade-delete worked fine (which doesn't work, it seems, in BEA Weblogic 7 properly too). -
2. Re: CMP ejbRemove(): Underlying collection has been modified
timfox Jul 27, 2002 1:00 PM (in response to sergeibatiuk)You need to remove the item from the iterator
ie iter.remove(), just before the call to yourObject.remove().
you are getting a collectionmodifiedexception since your call yourObject.remove() removes the object from the collection you are currently iterating through thus making it invalid.
This is a side-effect of what the ejb2 spec mandates for what happens when you remove an entity.
There is a whole section in the ejb2 spec on the correct semantics for adding and removing entities from cmr relations.