HHH-8406 - fix for EntityManagerFactoryRegistry not being thread safe

This commit is contained in:
Scott Marlow 2013-08-01 21:36:58 -04:00
parent cd812b6d65
commit 7146435a42
1 changed files with 5 additions and 4 deletions

View File

@ -139,10 +139,11 @@ public class EntityManagerFactoryRegistry {
if (entityManagerFactorySet == null) {
throw new HibernateException( "registry does not contain entity manager factory: " + name);
}
if (entityManagerFactorySet.size() > 1) {
throw new HibernateException( "registry contains more than one (" + entityManagerFactorySet.size()+ ") entity manager factories: " + name);
synchronized (entityManagerFactorySet) {
if (entityManagerFactorySet.size() > 1) {
throw new HibernateException( "registry contains more than one (" + entityManagerFactorySet.size()+ ") entity manager factories: " + name);
}
return entityManagerFactorySet.iterator().next();
}
return entityManagerFactorySet.iterator().next();
}
}