It looks like you're no longer calling remove() on the bean itself though; you need to do that too - i.remove() just removes it from the collection, it doesn't delete the bean.
Al. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Matthew Hixson > Sent: 10 September 2003 07:40 > To: [EMAIL PROTECTED] > Subject: Re: [JBoss-user] Removing items from a CMR collection > > > Thanks, Scott. I got this working. > > public boolean emptyCart(CartLocal cart) { > Collection cartContentList = cart.getCartContentList(); > Iterator i = cartContentList.iterator(); > while(i.hasNext()) { > i.next(); // advance the pointer down the list > i.remove(); > } > return true; > } > > -M@ > > On Tuesday, September 9, 2003, at 10:02 PM, Scott M Stark wrote: > > > > > This is basic java.util.Collection behavior. From the > > java.util.Iterator.remove javadoc: > > > > public void remove() > > > > Removes from the underlying collection the last element returned > > by the iterator (optional operation). This method can be > called only > > once per call to next. The behavior of an iterator is > unspecified if > > the underlying collection is modified while the iteration is in > > progress in any way other than by calling this method. > > > > -- > > xxxxxxxxxxxxxxxxxxxxxxxx > > Scott Stark > > Chief Technology Officer > > JBoss Group, LLC > > xxxxxxxxxxxxxxxxxxxxxxxx > > > > Matthew Hixson wrote: > > > >> I have the following method while takes as an argument a > reference to > >> a CartBean (a shopping cart). This method's jobs is to remove > >> everything (CartContentBeans) from the shopping cart. > >> public boolean emptyCart(CartLocal cart) { > >> Collection cartContentList = cart.getCartContentList(); > >> Iterator i = cartContentList.iterator(); > >> while(i.hasNext()) { > >> CartContentLocal cartContent = (CartContentLocal) i.next(); > >> try { > >> cartContentList.remove(cartContent); > >> cartContent.remove(); > >> } catch (RemoveException ralph) { > >> _systemLogger.error(ralph.getMessage()); > >> return false; > >> } > >> } > >> return true; > >> } > >> This method worked under Resin, but JBoss is giving me the > exception > >> below. Of course the collection has been modified; I'm iterating > >> over it so that I can remove things from it. Do I have > to build an > >> array of cartContentId Integers that I want to remove and then > >> iterate over that, gaining a reference to each > CartContentBean with > >> CartContentLocalHome.findByPrimaryKey()? That seems a bit silly. > >> Any thoughts would be welcome. > >> Thanks, > >> -M@ > > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by:ThinkGeek > > Welcome to geek heaven. > > http://thinkgeek.com/sf > > _______________________________________________ > > JBoss-user mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/jboss-user > > > > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user