org.apache.openjpa.persistence
Class JPAFacadeHelper

java.lang.Object
  extended by org.apache.openjpa.persistence.JPAFacadeHelper

public class JPAFacadeHelper
extends Object

Helper class for switching between OpenJPA's JPA facade and the underlying Broker kernel.

Since:
1.0.0

Field Summary
static String EM_KEY
           
static String EMF_KEY
           
 
Constructor Summary
JPAFacadeHelper()
           
 
Method Summary
static Object fromOpenJPAObjectId(Object oid)
          Translate from a OpenJPA identity object to a Persistence one.
static Class fromOpenJPAObjectIdClass(Class oidClass)
          Translate from a OpenJPA identity class to a native one.
static ClassMetaData getMetaData(EntityManager em, Class cls)
          Returns the ClassMetaData associated with the persistent type cls.
static ClassMetaData getMetaData(EntityManagerFactory emf, Class cls)
          Returns the ClassMetaData associated with the persistent type cls.
static ClassMetaData getMetaData(Object o)
          Returns the ClassMetaData associated with the persistent object o.
static Broker toBroker(EntityManager em)
          Return the underlying broker for the given entity manager facade.
static BrokerFactory toBrokerFactory(EntityManagerFactory emf)
          Return the underlying broker factory for the given persistence manager factory facade.
static OpenJPAEntityManager toEntityManager(Broker broker)
          Return a persistence manager facade to the given broker retaining previously associated persistence context type.
static OpenJPAEntityManagerFactory toEntityManagerFactory(BrokerFactory factory)
           
static Object toOpenJPAObjectId(ClassMetaData meta, Object oid)
          Translate from a Persistence identity object to a OpenJPA one.
static Collection<Object> toOpenJPAObjectIds(ClassMetaData meta, Collection<Object> oids)
          Return a collection of OpenJPA oids for the given native oid collection.
static Object[] toOpenJPAObjectIds(ClassMetaData meta, Object... oids)
          Return an array of OpenJPA oids for the given native oid array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EM_KEY

public static final String EM_KEY
See Also:
Constant Field Values

EMF_KEY

public static final String EMF_KEY
See Also:
Constant Field Values
Constructor Detail

JPAFacadeHelper

public JPAFacadeHelper()
Method Detail

toEntityManagerFactory

public static OpenJPAEntityManagerFactory toEntityManagerFactory(BrokerFactory factory)

toBrokerFactory

public static BrokerFactory toBrokerFactory(EntityManagerFactory emf)
Return the underlying broker factory for the given persistence manager factory facade.


toEntityManager

public static OpenJPAEntityManager toEntityManager(Broker broker)
Return a persistence manager facade to the given broker retaining previously associated persistence context type.


toBroker

public static Broker toBroker(EntityManager em)
Return the underlying broker for the given entity manager facade.


getMetaData

public static ClassMetaData getMetaData(Object o)
Returns the ClassMetaData associated with the persistent object o.


getMetaData

public static ClassMetaData getMetaData(EntityManager em,
                                        Class cls)
Returns the ClassMetaData associated with the persistent type cls.


getMetaData

public static ClassMetaData getMetaData(EntityManagerFactory emf,
                                        Class cls)
Returns the ClassMetaData associated with the persistent type cls.


fromOpenJPAObjectId

public static Object fromOpenJPAObjectId(Object oid)
Translate from a OpenJPA identity object to a Persistence one.


toOpenJPAObjectId

public static Object toOpenJPAObjectId(ClassMetaData meta,
                                       Object oid)
Translate from a Persistence identity object to a OpenJPA one. If the provided oid isn't of the expected type a UserException will be thrown.


toOpenJPAObjectIds

public static Object[] toOpenJPAObjectIds(ClassMetaData meta,
                                          Object... oids)
Return an array of OpenJPA oids for the given native oid array.


toOpenJPAObjectIds

public static Collection<Object> toOpenJPAObjectIds(ClassMetaData meta,
                                                    Collection<Object> oids)
Return a collection of OpenJPA oids for the given native oid collection.


fromOpenJPAObjectIdClass

public static Class fromOpenJPAObjectIdClass(Class oidClass)
Translate from a OpenJPA identity class to a native one.



Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.