I am writing some tests for a persistance layer I've been working on and I've ran into an exception that that I'm having trouble dealing with, a ConcurrentModificationException it's happening at org.hibernate.mapping.Table.cleanseUniqueKeyMap(Table.java:291)
.
Which turns out to be this line of code:
final Map.Entry<String,UniqueKey> uniqueKeyEntry = uniqueKeyEntries.next();
After doing a little research I've found out that the exception is caused by one thread modifying this collection while this thread is iterating over it. That being said I feel like there's nothing that I'm doing that's causing this to happen any suggestions on troubleshooting?
BTW, Im using hibernate 4.1.5
. Idk if that clears anything up or not. Here's my test:
@Test
public void testCreateMobsterUser() {
try {
final MobsterUserDAO test = new MobsterUserDAO(); //throws exception
//does stuff w/ return value...
As you can see we try and initialize the dao Let's see that code:
public MobsterUserDAO() {
super(MobsterUser.class);
}
Well that didn't show us much so let's look at the generic dao constructor and see if you see the problem there.
public MobsterBaseHibernateDAO(final Class<T> clazz) {
this.clazz = clazz;
//This next line is where the exception is actually occuring
final EntityManagerFactory factory = Persistence.createEntityManagerFactory("mobsterdb");
this.manager = (HibernateEntityManager) factory.createEntityManager();
}
Now I'm not sure what kind of rabbit hole Persistance.createEntityManagerFactory is, but that is the last line of my code that gets executed before the exception occurs.