-->
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.  [ 6 posts ] 
Author Message
 Post subject: ConcurrentModificationException when iterating
PostPosted: Wed Aug 18, 2004 6:09 pm 
Newbie

Joined: Fri Oct 31, 2003 3:14 pm
Posts: 12
Location: New York, NY
Hibernate version: 2.1.2

While using a for loop to iterator over a collection returned from a Hibernate object, I am getting a ConcurrentModificationException. I am not adding or removing things from this collection, just iterating over it.

I know that's not a lot of info, but there's not a lot here. Any ideas on what to be looking for? Hibernate should have alread loaded the collection before passing it back right?

Thanks,
Patrick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 9:34 pm 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
Is it possible another thread is modifying your collection? What are you doing in the for loop? It might be possible you are violating the contract in some other way in which case it will fail-fast.

If its not too much trouble, try posting some code.


Top
 Profile  
 
 Post subject: Re: ConcurrentModificationException when iterating
PostPosted: Thu Aug 19, 2004 12:47 am 
Regular
Regular

Joined: Wed Nov 26, 2003 6:22 am
Posts: 76
Location: Stockholm
pburleson wrote:
Hibernate version: 2.1.2

While using a for loop to iterator over a collection returned from a Hibernate object, I am getting a ConcurrentModificationException. I am not adding or removing things from this collection, just iterating over it.


Isn't there an evict(Object) or evictCollection(...) method? Or try to clone() the collection before iterating it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 2:52 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
how are you managing your session?
in your problem, 2 thread may hit the same session... the session isn't threadsafe...

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 10:12 am 
Newbie

Joined: Fri Oct 31, 2003 3:14 pm
Posts: 12
Location: New York, NY
I am just iterating over the collection as returned. This is the only active thread. And unless hibernate is filling the collection in its own internal thread, then I don't know what is causing the concurrent access.

I'm going to dig further into the code. The DAO class was written by another team member.

Thanks,
Patrick


Top
 Profile  
 
 Post subject: ConcurrentModificationException when iterating [SOLVED]
PostPosted: Thu Aug 19, 2004 2:39 pm 
Newbie

Joined: Fri Oct 31, 2003 3:14 pm
Posts: 12
Location: New York, NY
Yep, the DAO I am using to get objects out was modifying the Set. Gotta change that.

Thanks for all the responses.

Patrick


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.