title: Why is a ConcurrentModificationException thrown and how to debug it
body: <p>I am using a <code>Collection</code> (a <code>HashMap</code> used indirectly by the JPA, it so happens), but apparently randomly the code throws a <code>ConcurrentModificationException</code>. What is causing it and how do I fix this problem? By using some synchronization, perhaps?</p>
  
  <p>Here is the full stack-trace:</p>
  
  <pre><code>Exception in thread "pool-1-thread-1" java.util.ConcurrentModificationException
          at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
          at java.util.HashMap$ValueIterator.next(Unknown Source)
          at org.hibernate.collection.AbstractPersistentCollection$IteratorProxy.next(AbstractPersistentCollection.java:555)
          at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
          at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
          at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
          at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
          at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
  </code></pre>