Package org.apache.openjpa.persistence
Class OpenJPAPersistence
java.lang.Object
org.apache.openjpa.persistence.OpenJPAPersistence
Static helper methods for JPA users.
- Since:
- 0.4.0
- Author:
- Abe White
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Deprecated.static final String
Deprecated.useJPAFacadeHelper
instead. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic OpenJPAEntityManager
cast
(jakarta.persistence.EntityManager em) Return the OpenJPA facade to the given entity manager.static OpenJPAEntityManagerFactory
cast
(jakarta.persistence.EntityManagerFactory emf) Return the OpenJPA facade to the given entity manager factory.static OpenJPAQuery
cast
(jakarta.persistence.Query q) Return the OpenJPA facade to the given query.static void
Close the given resource.static OpenJPAEntityManagerFactory
createEntityManagerFactory
(String name, String resource) Returns a newOpenJPAEntityManagerFactory
specified byname
in an XML configuration file at the resource locationresource
.static OpenJPAEntityManagerFactory
createEntityManagerFactory
(String name, String resource, Map map) Returns a newOpenJPAEntityManagerFactory
specified byname
in an XML configuration file at the resource locationresource
, applying the properties specified inmap
as overrides.static OpenJPAEntityManagerFactory
createEntityManagerFactory
(String jndiLocation, Context context) Returns theEntityManagerFactory
at the JNDI location specified byjndiLocation
in the contextcontext
.static Object
Deprecated.useJPAFacadeHelper
instead.static Class
fromOpenJPAObjectIdClass
(Class oidClass) Deprecated.useJPAFacadeHelper
instead.static OpenJPAEntityManager
Return the entity manager for the given object, if one can be determined from just the object alone.static OpenJPAEntityManagerFactory
Returns theOpenJPAEntityManagerFactory
specified by your OpenJPA defaults.static OpenJPAEntityManagerFactory
Returns theOpenJPAEntityManagerFactory
specified by your OpenJPA defaults, usingmap
as overrides.static ClassMetaData
getMetaData
(jakarta.persistence.EntityManagerFactory factory, Class cls) Deprecated.useJPAFacadeHelper
instead.static ClassMetaData
getMetaData
(jakarta.persistence.EntityManager em, Class cls) Deprecated.useJPAFacadeHelper
instead.static ClassMetaData
Deprecated.useJPAFacadeHelper
instead.static boolean
isManagedType
(jakarta.persistence.EntityManager em, Class cls) Returns true if the specified class is an entity or embeddable type.static Broker
toBroker
(jakarta.persistence.EntityManager em) Deprecated.useJPAFacadeHelper
instead.static BrokerFactory
toBrokerFactory
(jakarta.persistence.EntityManagerFactory factory) Deprecated.useJPAFacadeHelper
instead.static OpenJPAEntityManager
toEntityManager
(Broker broker) Deprecated.useJPAFacadeHelper
instead.static OpenJPAEntityManagerFactory
toEntityManagerFactory
(BrokerFactory factory) Deprecated.useJPAFacadeHelper
instead.static Object
toOpenJPAObjectId
(ClassMetaData meta, Object oid) Deprecated.useJPAFacadeHelper
instead.static Object[]
toOpenJPAObjectIds
(ClassMetaData meta, Object... oids) Deprecated.useJPAFacadeHelper
instead.static Collection
toOpenJPAObjectIds
(ClassMetaData meta, Collection oids) Deprecated.useJPAFacadeHelper
instead.
-
Field Details
-
EM_KEY
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.- See Also:
-
EMF_KEY
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.- See Also:
-
-
Constructor Details
-
OpenJPAPersistence
public OpenJPAPersistence()
-
-
Method Details
-
cast
Return the OpenJPA facade to the given entity manager factory. -
cast
Return the OpenJPA facade to the given entity manager. -
cast
Return the OpenJPA facade to the given query. -
getEntityManagerFactory
Returns theOpenJPAEntityManagerFactory
specified by your OpenJPA defaults. This method will return the same logical factory for each invocation. -
getEntityManagerFactory
Returns theOpenJPAEntityManagerFactory
specified by your OpenJPA defaults, usingmap
as overrides. This method will return the same logical factory for invocations with the same overrides. -
createEntityManagerFactory
Returns a newOpenJPAEntityManagerFactory
specified byname
in an XML configuration file at the resource locationresource
. Ifname
isnull
, uses the first resource found in the specified location, regardless of the name specified in the XML resource or the name of the jar that the resource is contained in. Ifresource
isnull
, uses the spec-definedMETA-INF/persistence.xml
resource. This method only resolvesOpenJPAEntityManagerFactory
instances. -
createEntityManagerFactory
public static OpenJPAEntityManagerFactory createEntityManagerFactory(String name, String resource, Map map) Returns a newOpenJPAEntityManagerFactory
specified byname
in an XML configuration file at the resource locationresource
, applying the properties specified inmap
as overrides. Ifname
isnull
, uses the first resource found in the specified location, regardless of the name specified in the XML resource or the name of the jar that the resource is contained in. Ifresource
isnull
, uses the spec-definedMETA-INF/persistence.xml
resource. This method only resolvesOpenJPAEntityManagerFactory
instances. -
createEntityManagerFactory
public static OpenJPAEntityManagerFactory createEntityManagerFactory(String jndiLocation, Context context) Returns theEntityManagerFactory
at the JNDI location specified byjndiLocation
in the contextcontext
. Ifcontext
isnull
,new InitialContext()
will be used. -
getEntityManager
Return the entity manager for the given object, if one can be determined from just the object alone. This method will succeed for instances that are enhanced, that were loaded from the database (rather than being constructed withnew
), or that were created throughOpenJPAEntityManager.createInstance(java.lang.Class<T>)
. -
close
Close the given resource. The resource can be an extent iterator, query result, large result set relation, or any closeable OpenJPA component. -
isManagedType
Returns true if the specified class is an entity or embeddable type. -
toEntityManagerFactory
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
toBrokerFactory
@Deprecated public static BrokerFactory toBrokerFactory(jakarta.persistence.EntityManagerFactory factory) Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
toEntityManager
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
toBroker
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
getMetaData
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
getMetaData
@Deprecated public static ClassMetaData getMetaData(jakarta.persistence.EntityManager em, Class cls) Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
getMetaData
@Deprecated public static ClassMetaData getMetaData(jakarta.persistence.EntityManagerFactory factory, Class cls) Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
fromOpenJPAObjectId
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
toOpenJPAObjectId
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
toOpenJPAObjectIds
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
toOpenJPAObjectIds
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization. -
fromOpenJPAObjectIdClass
Deprecated.useJPAFacadeHelper
instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
-
JPAFacadeHelper
instead.