tolerate EM / EMF proxies as arguments to toBroker() / toBrokerFactory().

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@471497 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2006-11-05 19:24:08 +00:00
parent 607b863ec2
commit 346f6a0d0c
1 changed files with 8 additions and 2 deletions

View File

@ -83,8 +83,11 @@ public class OpenJPAPersistence
* 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 @@ public class OpenJPAPersistence
* 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();
}