You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by rm...@apache.org on 2020/10/01 07:45:56 UTC

[openjpa] branch master updated: [OPENJPA-2834] enable to bypass synchronizeMappings when calling getProperties

This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b68db6  [OPENJPA-2834] enable to bypass synchronizeMappings when calling getProperties
0b68db6 is described below

commit 0b68db6ba164943d8470d46fb4de326a19fc9485
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Thu Oct 1 09:45:50 2020 +0200

    [OPENJPA-2834] enable to bypass synchronizeMappings when calling getProperties
---
 .../apache/openjpa/persistence/EntityManagerFactoryImpl.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
index ff06de6..9242ccd 100644
--- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
+++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
@@ -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);