[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [eclipselink-users] ConcurrentModificationException
|
Please create an automated test case failing and attach to a bug.
You could reuse some of the setup for your test from existing automated
test case like the one provided on
https://bugs.eclipse.org/bugs/show_bug.cgi?id=270762
-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of cmathrusse
Sent: Thursday, September 03, 2009 3:06 PM
To: eclipselink-users@xxxxxxxxxxx
Subject: [eclipselink-users] ConcurrentModificationException
I'm using EclipseLink 1.1.2 (just upgraded from 1.1.1 which I also had
the
same issue with)
I have an OrderProcess entity that contains a list of Addresses. It is a
one
sided relationship.
public class OrderProcess {
@OneToMany
@JoinTable(
name = "ORDER_PROCESS_ADDRESS",
joinColumns = @JoinColumn(name = "ORDER_PROCESS_ID"),
inverseJoinColumns = @JoinColumn(name = "ADDRESS_ID"))
private List<Address> addresses;
....
}
I'm attempting to update the address list on the OrderProcess. I don't
want
to retain any relationships that currently exist. So I'm attempting to
simply replace the existing Address list with a new one. Something like
the
following.
java.util.List<Address> orderAddresses = new
java.util.ArrayList<Address>();
for(Address address : externalAddresses) {
// Get a reference to the entity
address = addressFacade.findExisting(address.getExternalId(),
address.getNameType(), address.getOrganization(),
process.getSourceRecordDate());
if(!orderAddresses.contains(address)) {
orderAddresses.add(address);
}
}
// assign the addresses to the process
process.setAddresses(orderAddresses);
process.setModDate(Calendar.getUTCInstance());
Process updated = em.merge(process);
em.flush();
The above code executes successfully except when there are existing
Addresses associated to the OrderProcess. When the call to flush() gets
executed I get the following exception:
javax.ejb.TransactionRolledbackLocalException: Exception thrown from
bean;
nested exception is: java.util.ConcurrentModificationException
java.util.ConcurrentModificationException
at
java.util.IdentityHashMap$IdentityHashMapIterator.nextIndex(IdentityHash
Map.java:715)
at
java.util.IdentityHashMap$KeyIterator.next(IdentityHashMap.java:804)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChange
s(UnitOfWorkImpl.java:567)
at
org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writ
eChanges(RepeatableWriteUnitOfWork.java:308)
at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManag
erImpl.java:527)
at
com.sun.enterprise.util.EntityManagerWrapper.flush(EntityManagerWrapper.
java:331)
If I delete the associated Addresses from the ORDER_PROCESS_ADDRESS
table
and reprocess the OrderProcess then everything functions as expected
without
any Exception.
So it seems to me that I am incorrectly assigning the Addresses. Do I
need
to remove them prior to the assignment? Or is there another way that I
need
to perform the assignment?
Thanks for the help..
--
View this message in context:
http://www.nabble.com/ConcurrentModificationException-tp25282265p2528226
5.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users