Class OpenJPAPersistence


  • public class OpenJPAPersistence
    extends java.lang.Object
    Static helper methods for JPA users.
    Since:
    0.4.0
    Author:
    Abe White
    • Field Detail

      • EM_KEY

        @Deprecated
        public static final java.lang.String EM_KEY
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
        See Also:
        Constant Field Values
      • EMF_KEY

        @Deprecated
        public static final java.lang.String EMF_KEY
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
        See Also:
        Constant Field Values
    • Constructor Detail

      • OpenJPAPersistence

        public OpenJPAPersistence()
    • Method Detail

      • cast

        public static OpenJPAEntityManagerFactory cast​(jakarta.persistence.EntityManagerFactory emf)
        Return the OpenJPA facade to the given entity manager factory.
      • cast

        public static OpenJPAEntityManager cast​(jakarta.persistence.EntityManager em)
        Return the OpenJPA facade to the given entity manager.
      • cast

        public static OpenJPAQuery cast​(jakarta.persistence.Query q)
        Return the OpenJPA facade to the given query.
      • getEntityManagerFactory

        public static OpenJPAEntityManagerFactory getEntityManagerFactory​(java.util.Map map)
        Returns the OpenJPAEntityManagerFactory specified by your OpenJPA defaults, using map as overrides. This method will return the same logical factory for invocations with the same overrides.
      • createEntityManagerFactory

        public static OpenJPAEntityManagerFactory createEntityManagerFactory​(java.lang.String name,
                                                                             java.lang.String resource)
        Returns a new OpenJPAEntityManagerFactory specified by name in an XML configuration file at the resource location resource. If name is null, 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. If resource is null, uses the spec-defined META-INF/persistence.xml resource. This method only resolves OpenJPAEntityManagerFactory instances.
      • createEntityManagerFactory

        public static OpenJPAEntityManagerFactory createEntityManagerFactory​(java.lang.String name,
                                                                             java.lang.String resource,
                                                                             java.util.Map map)
        Returns a new OpenJPAEntityManagerFactory specified by name in an XML configuration file at the resource location resource, applying the properties specified in map as overrides. If name is null, 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. If resource is null, uses the spec-defined META-INF/persistence.xml resource. This method only resolves OpenJPAEntityManagerFactory instances.
      • createEntityManagerFactory

        public static OpenJPAEntityManagerFactory createEntityManagerFactory​(java.lang.String jndiLocation,
                                                                             javax.naming.Context context)
        Returns the EntityManagerFactory at the JNDI location specified by jndiLocation in the context context. If context is null, new InitialContext() will be used.
      • getEntityManager

        public static OpenJPAEntityManager getEntityManager​(java.lang.Object o)
        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 with new), or that were created through OpenJPAEntityManager.createInstance(java.lang.Class<T>).
      • close

        public static void close​(java.lang.Object o)
        Close the given resource. The resource can be an extent iterator, query result, large result set relation, or any closeable OpenJPA component.
      • isManagedType

        public static boolean isManagedType​(jakarta.persistence.EntityManager em,
                                            java.lang.Class cls)
        Returns true if the specified class is an entity or embeddable type.
      • toBrokerFactory

        @Deprecated
        public static BrokerFactory toBrokerFactory​(jakarta.persistence.EntityManagerFactory factory)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • toEntityManager

        @Deprecated
        public static OpenJPAEntityManager toEntityManager​(Broker broker)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • toBroker

        @Deprecated
        public static Broker toBroker​(jakarta.persistence.EntityManager em)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • getMetaData

        @Deprecated
        public static ClassMetaData getMetaData​(java.lang.Object o)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • getMetaData

        @Deprecated
        public static ClassMetaData getMetaData​(jakarta.persistence.EntityManager em,
                                                java.lang.Class cls)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • getMetaData

        @Deprecated
        public static ClassMetaData getMetaData​(jakarta.persistence.EntityManagerFactory factory,
                                                java.lang.Class cls)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • fromOpenJPAObjectId

        @Deprecated
        public static java.lang.Object fromOpenJPAObjectId​(java.lang.Object oid)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • toOpenJPAObjectId

        @Deprecated
        public static java.lang.Object toOpenJPAObjectId​(ClassMetaData meta,
                                                         java.lang.Object oid)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • toOpenJPAObjectIds

        @Deprecated
        public static java.lang.Object[] toOpenJPAObjectIds​(ClassMetaData meta,
                                                            java.lang.Object... oids)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • toOpenJPAObjectIds

        @Deprecated
        public static java.util.Collection toOpenJPAObjectIds​(ClassMetaData meta,
                                                              java.util.Collection oids)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.
      • fromOpenJPAObjectIdClass

        @Deprecated
        public static java.lang.Class fromOpenJPAObjectIdClass​(java.lang.Class oidClass)
        Deprecated.
        use JPAFacadeHelper instead. This method pierces the published-API boundary, as does the JPAFacadeHelper utilization.