openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r471497 - /incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java
Date Sun, 05 Nov 2006 19:24:09 GMT
Author: pcl
Date: Sun Nov  5 11:24:08 2006
New Revision: 471497

URL: http://svn.apache.org/viewvc?view=rev&rev=471497
Log:
tolerate EM / EMF proxies as arguments to toBroker() / toBrokerFactory().

Modified:
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java?view=diff&rev=471497&r1=471496&r2=471497
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistence.java
Sun Nov  5 11:24:08 2006
@@ -83,8 +83,11 @@
      * factory facade.
      */
     public static BrokerFactory toBrokerFactory(EntityManagerFactory emf) {
-        return (emf == null) ? null
-            : ((EntityManagerFactoryImpl) emf).getBrokerFactory();
+        if (emf == null)
+            return null;
+        emf = (EntityManagerFactory) 
+            ((OpenJPAEntityManagerFactory) emf).getUserObject(EMF_KEY);        
+        return ((EntityManagerFactoryImpl) emf).getBrokerFactory();
     }
 
     /**
@@ -117,6 +120,9 @@
      * Return the underlying broker for the given entity manager facade.
      */
     public static Broker toBroker(EntityManager em) {
+        if (em == null)
+            return null;
+        em = (EntityManager) ((OpenJPAEntityManager) em).getUserObject(EM_KEY);
         return (em == null) ? null : ((EntityManagerImpl) em).getBroker();
     }
 



Mime
View raw message