mirror of https://github.com/apache/openjpa.git
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:
parent
607b863ec2
commit
346f6a0d0c
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue