-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ConcurrentModificationException ?
PostPosted: Mon Jul 05, 2004 9:46 am 
Beginner
Beginner

Joined: Mon Sep 15, 2003 9:10 am
Posts: 43
I've got a concurrency pb :

For info, e is an entreprise object with a set of contact;

Code:
for (Iterator itF = e.getContacts().iterator(); itF.hasNext();) {
   Contact c = (Contact) itF.next();
   if (c.getId()>4){
        e.getContacts().remove(c);
   }
}


What is the better way do delete elts of an existing Set ?

Code:
for (Iterator itF = new ArrayList(e.getContacts()).iterator(); itF .hasNext();)
?


Thanks,

Fabien.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 05, 2004 10:17 am 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Now before someone jumps in and says this isn't really a hibernate question but a plain old Java one, I'll give the answer ;)

Just call itF.remove() instead of e.getContacts().remove(c) and the ConcurrentModificationException will go away.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.