[OPENJPA-2834] enable to bypass synchronizeMappings when calling getProperties

This commit is contained in:
Romain Manni-Bucau 2020-10-01 09:45:50 +02:00
parent 9fa619f94e
commit 0b68db6ba1
1 changed files with 10 additions and 2 deletions

View File

@ -119,7 +119,7 @@ public class EntityManagerFactoryImpl
if (emEmptyPropsProperties != null) {
props.putAll(emEmptyPropsProperties);
} else {
props.putAll(createEntityManager().getProperties());
props.putAll(doCreateEM(SynchronizationType.SYNCHRONIZED, null, true).getProperties());
}
// no need to sync or volatile, worse case concurrent threads create 2 instances
// we just want to avoid to do it after some "init" phase
@ -198,6 +198,12 @@ public class EntityManagerFactoryImpl
*/
@Override
public OpenJPAEntityManagerSPI createEntityManager(SynchronizationType synchronizationType, Map props) {
return doCreateEM(synchronizationType, props, false);
}
private OpenJPAEntityManagerSPI doCreateEM(SynchronizationType synchronizationType,
Map props,
boolean byPassSynchronizeMappings) {
if (synchronizationType == null) {
throw new NullPointerException("SynchronizationType must not be null");
}
@ -271,7 +277,9 @@ public class EntityManagerFactoryImpl
}
validateCfNameProps(conf, cfName, cf2Name);
Broker broker = _factory.newBroker(user, pass, managed, retainMode, false, cfName, cf2Name);
Broker broker = byPassSynchronizeMappings ?
conf.newBrokerInstance(user, pass) :
_factory.newBroker(user, pass, managed, retainMode, false, cfName, cf2Name);
// add autodetach for close and rollback conditions to the configuration
broker.setAutoDetach(AutoDetach.DETACH_CLOSE, true);