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();
while(childIterator.hasNext())
{
    MyChild child = (MyChild)childIterator.next();
    if(child.meetsSomeCriteriaForRemoval())
      childIterator.remove();
}

System.out.println("Num children: " + children.size());
parent.setChildren(children);
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?

Thanks,
Dave


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3953057#3953057

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3953057

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to