Class JakartaEntityManagerFactory

    • Field Detail

      • LOGGER

        public static final org.datanucleus.util.NucleusLogger LOGGER
        Logger for enhancing.
    • Constructor Detail

      • JakartaEntityManagerFactory

        public JakartaEntityManagerFactory​(jakarta.persistence.spi.PersistenceUnitInfo unitInfo,
                                           Map overridingProps)
        Constructor when working in a JavaEE environment.
        Parameters:
        unitInfo - The "persistent-unit" info
        overridingProps - factory properties overriding those in the "persistence-unit"
      • JakartaEntityManagerFactory

        public JakartaEntityManagerFactory​(org.datanucleus.metadata.PersistenceUnitMetaData pumd,
                                           Map overridingProps)
        Convenience constructor to allow for dynamic persistence-unit creation in JavaSE.
        Parameters:
        pumd - Persistence unit metadata
        overridingProps - Properties overriding those defined for this unit
      • JakartaEntityManagerFactory

        public JakartaEntityManagerFactory​(String unitName,
                                           Map overridingProps)
        Constructor when working in a JavaSE environment.
        Parameters:
        unitName - Name of the "persistent-unit" to use
        overridingProps - factory properties overriding those in the "persistence-unit"
    • Method Detail

      • getNucleusContext

        public org.datanucleus.NucleusContext getNucleusContext()
      • isContainerManaged

        public boolean isContainerManaged()
        Accessor for whether the EMF is managed by a container (JavaEE).
        Returns:
        Whether managed by a container
      • getName

        public String getName()
      • close

        public void close()
        Method to close the factory.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface jakarta.persistence.EntityManagerFactory
      • isOpen

        public boolean isOpen()
        Accessor for whether the factory is open
        Specified by:
        isOpen in interface jakarta.persistence.EntityManagerFactory
        Returns:
        Whether it is open
      • getQueryCache

        public JakartaQueryCache getQueryCache()
        Accessor for the query results cache.
        Returns:
        Query results cache
      • getQueryGenericCompilationCache

        public org.datanucleus.store.query.cache.QueryCompilationCache getQueryGenericCompilationCache()
        Accessor for the query generic compilation cache.
        Returns:
        Query generic compilation cache
      • getQueryDatastoreCompilationCache

        public org.datanucleus.store.query.cache.QueryDatastoreCompilationCache getQueryDatastoreCompilationCache()
        Accessor for the query datastore compilation cache.
        Returns:
        Query datastore compilation cache
      • addNamedQuery

        public void addNamedQuery​(String name,
                                  jakarta.persistence.Query query)
        Method to save the specified query under the provided name, so it can be used as a named query. If there is already a named query of this name it is overwritten.
        Specified by:
        addNamedQuery in interface jakarta.persistence.EntityManagerFactory
        Parameters:
        query - The query whose definition we save as named
      • createEntityManager

        public jakarta.persistence.EntityManager createEntityManager()
        Method to create an (application-managed) entity manager.
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
        Returns:
        The Entity Manager
      • createEntityManager

        public jakarta.persistence.EntityManager createEntityManager​(Map overridingProps)
        Method to create an (application-managed) entity manager with the specified properties. This creates a new underlying context since each EMF is locked when created to stop config changes.
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
        Parameters:
        overridingProps - Properties to use for this manager
        Returns:
        The Entity Manager
      • createEntityManager

        public jakarta.persistence.EntityManager createEntityManager​(jakarta.persistence.SynchronizationType syncType)
        Create a new JTA application-managed EntityManager with the specified synchronization type. This method returns a new EntityManager instance each time it is invoked. The isOpen method will return true on the returned instance.
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
        Parameters:
        syncType - how and when the entity manager should be synchronized with the current JTA transaction
        Returns:
        entity manager instance
        Throws:
        IllegalStateException - if the entity manager factory has been configured for resource-local entity managers or has been closed
      • createEntityManager

        public jakarta.persistence.EntityManager createEntityManager​(jakarta.persistence.SynchronizationType syncType,
                                                                     Map overridingProps)
        Create a new JTA application-managed EntityManager with the specified synchronization type and Map of properties. This method returns a new EntityManager instance each time it is invoked. The isOpen method will return true on the returned instance.
        Specified by:
        createEntityManager in interface jakarta.persistence.EntityManagerFactory
        Parameters:
        syncType - how and when the entity manager should be synchronized with the current JTA transaction
        overridingProps - properties for entity manager; may be null
        Returns:
        entity manager instance
        Throws:
        IllegalStateException - if the entity manager factory has been configured for resource-local entity managers or has been closed
      • newEntityManager

        protected jakarta.persistence.EntityManager newEntityManager​(org.datanucleus.PersistenceNucleusContext nucleusCtx,
                                                                     jakarta.persistence.PersistenceContextType contextType,
                                                                     jakarta.persistence.SynchronizationType syncType)
        Creates an EntityManager. Override if you want to return a different type that implements this interface.
        Parameters:
        nucleusCtx - Nucleus Context
        contextType - The persistence context type
        syncType - Synchronization type
        Returns:
        The EntityManager
      • initialiseNucleusContext

        protected org.datanucleus.PersistenceNucleusContext initialiseNucleusContext​(org.datanucleus.metadata.PersistenceUnitMetaData unitMetaData,
                                                                                     Map overridingProps,
                                                                                     org.datanucleus.plugin.PluginManager pluginMgr)
        Method to initialise a PersistenceManagerFactory that will control the persistence. If the unitMetaData is null will simply create a default context without initialising any MetaData etc. If there is a unitMetaData then all metadata for that unit will be loaded/initialised.
        Parameters:
        unitMetaData - The "persistence-unit" metadata (if any)
        overridingProps - Properties to override all others
        pluginMgr - Plugin Manager
        Returns:
        The PersistenceManagerFactory
      • getProperties

        public Map<String,​Object> getProperties()
        Get the properties and associated values that are in effect for the entity manager factory. Changing the contents of the map does not change the configuration in effect.
        Specified by:
        getProperties in interface jakarta.persistence.EntityManagerFactory
        Returns:
        properties
      • getSupportedProperties

        public Set<String> getSupportedProperties()
        Get the names of the properties that are supported for use with the entity manager factory. These correspond to properties that may be passed to the methods of the EntityManagerFactory interface that take a properties argument. These include all standard properties as well as vendor-specific properties supported by the provider. These properties may or may not currently be in effect.
        Returns:
        properties and hints
      • assertIsClosed

        protected void assertIsClosed()
      • getCache

        public jakarta.persistence.Cache getCache()
        Accessor for the second level cache.
        Specified by:
        getCache in interface jakarta.persistence.EntityManagerFactory
        Returns:
        Level 2 cache
      • getMetamodel

        public jakarta.persistence.metamodel.Metamodel getMetamodel()
        Specified by:
        getMetamodel in interface jakarta.persistence.EntityManagerFactory
      • getCriteriaBuilder

        public jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
        Specified by:
        getCriteriaBuilder in interface jakarta.persistence.EntityManagerFactory
      • getPersistenceUnitUtil

        public jakarta.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
        Specified by:
        getPersistenceUnitUtil in interface jakarta.persistence.EntityManagerFactory
      • getIdentifier

        public Object getIdentifier​(Object entity)
        Specified by:
        getIdentifier in interface jakarta.persistence.PersistenceUnitUtil
      • isLoaded

        public boolean isLoaded​(Object entity,
                                String attrName)
        Specified by:
        isLoaded in interface jakarta.persistence.PersistenceUnitUtil
        Specified by:
        isLoaded in interface jakarta.persistence.PersistenceUtil
      • isLoaded

        public boolean isLoaded​(Object entity)
        Specified by:
        isLoaded in interface jakarta.persistence.PersistenceUnitUtil
        Specified by:
        isLoaded in interface jakarta.persistence.PersistenceUtil
      • unwrap

        public <T> T unwrap​(Class<T> cls)
        Return an object of the specified type to allow access to the provider-specific API. If the provider's EntityManagerFactory implementation does not support the specified class, the PersistenceException is thrown.
        Specified by:
        unwrap in interface jakarta.persistence.EntityManagerFactory
        Parameters:
        cls - the class of the object to be returned. This is normally either the underlying EntityManagerFactory implementation class or an interface that it implements.
        Returns:
        an instance of the specified class
        Throws:
        jakarta.persistence.PersistenceException - if the provider does not support the call.
      • getNamedEntityGraph

        public jakarta.persistence.EntityGraph getNamedEntityGraph​(String graphName)
      • getEntityGraphNames

        public Set<String> getEntityGraphNames()
      • getEntityGraphsByType

        public <T> List<jakarta.persistence.EntityGraph<? super T>> getEntityGraphsByType​(Class<T> entityClass)
      • addNamedEntityGraph

        public <T> void addNamedEntityGraph​(String graphName,
                                            jakarta.persistence.EntityGraph<T> graph)
        Specified by:
        addNamedEntityGraph in interface jakarta.persistence.EntityManagerFactory
      • deregisterEntityGraph

        public void deregisterEntityGraph​(String graphName)
      • getDefinedEntityGraphName

        public String getDefinedEntityGraphName()