Package org.apache.openjpa.persistence
Class EntityManagerFactoryImpl
java.lang.Object
org.apache.openjpa.persistence.EntityManagerFactoryImpl
- All Implemented Interfaces:
jakarta.persistence.EntityManagerFactory
,jakarta.persistence.PersistenceUnitUtil
,jakarta.persistence.PersistenceUtil
,Serializable
,Closeable
,OpenJPAEntityManagerFactory
,OpenJPAEntityManagerFactorySPI
public class EntityManagerFactoryImpl
extends Object
implements OpenJPAEntityManagerFactory, OpenJPAEntityManagerFactorySPI, Closeable, jakarta.persistence.PersistenceUnitUtil
Implementation of
EntityManagerFactory
that acts as a
facade to a BrokerFactory
.- Author:
- Marc Prud'hommeaux
- See Also:
-
Field Summary
Fields inherited from interface org.apache.openjpa.persistence.OpenJPAEntityManagerFactory
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS
-
Constructor Summary
ConstructorDescriptionDefault constructor provided for auto-instantiation.EntityManagerFactoryImpl
(BrokerFactory factory) Supply delegate on construction. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLifecycleListener
(Object listener, Class... classes) Register a listener for lifecycle-related events on the specified classes.<T> void
addNamedEntityGraph
(String graphName, jakarta.persistence.EntityGraph<T> entityGraph) void
addNamedQuery
(String name, jakarta.persistence.Query query) void
addTransactionListener
(Object listener) Register a listener for transaction-related events on the specified classes.void
close()
createEntityManager
(jakarta.persistence.SynchronizationType synchronizationType) createEntityManager
(jakarta.persistence.SynchronizationType synchronizationType, Map props) Creates and configures a entity manager with the given properties.createEntityManager
(Map props) Return an entity manager with the provided additional configuration settings.boolean
Delegate.jakarta.persistence.Cache
getCache()
Return the configuration for this factory.Gets the QueryBuilder with OpenJPA-extended capabilities.Gets a builder for dynamic queries.getIdentifier
(Object entity) Get the identifier for the specified entity.jakarta.persistence.PersistenceUnitUtil
Return properties describing this runtime.Access query result cache.Access the level 2 store cache.getStoreCache
(String cacheName) Access a named level 2 store cache.Get the properties supported by this runtime.getUserObject
(Object key) Get the value for the specified key from the map of user objects.int
hashCode()
boolean
boolean
boolean
isOpen()
protected EntityManagerImpl
newEntityManagerImpl
(Broker broker) Create a new entity manager around the given broker.putUserObject
(Object key, Object val) Put the specified key-value pair into the map of user objects.void
removeLifecycleListener
(Object listener) Remove a listener for lifecycle-related events.void
removeTransactionListener
(Object listener) Remove a listener for transaction-related events.void
setBrokerFactory
(BrokerFactory factory) Delegate must be provided before use.<T> T
-
Constructor Details
-
EntityManagerFactoryImpl
public EntityManagerFactoryImpl()Default constructor provided for auto-instantiation. -
EntityManagerFactoryImpl
Supply delegate on construction.
-
-
Method Details
-
getBrokerFactory
Delegate. -
setBrokerFactory
Delegate must be provided before use. -
getConfiguration
Description copied from interface:OpenJPAEntityManagerFactorySPI
Return the configuration for this factory.- Specified by:
getConfiguration
in interfaceOpenJPAEntityManagerFactory
- Specified by:
getConfiguration
in interfaceOpenJPAEntityManagerFactorySPI
-
getProperties
Description copied from interface:OpenJPAEntityManagerFactory
Return properties describing this runtime.- Specified by:
getProperties
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
getProperties
in interfaceOpenJPAEntityManagerFactory
-
putUserObject
Description copied from interface:OpenJPAEntityManagerFactory
Put the specified key-value pair into the map of user objects.- Specified by:
putUserObject
in interfaceOpenJPAEntityManagerFactory
-
getUserObject
Description copied from interface:OpenJPAEntityManagerFactory
Get the value for the specified key from the map of user objects.- Specified by:
getUserObject
in interfaceOpenJPAEntityManagerFactory
-
getStoreCache
Description copied from interface:OpenJPAEntityManagerFactory
Access the level 2 store cache. This cache acts as a proxy to all named caches.- Specified by:
getStoreCache
in interfaceOpenJPAEntityManagerFactory
-
getStoreCache
Description copied from interface:OpenJPAEntityManagerFactory
Access a named level 2 store cache.- Specified by:
getStoreCache
in interfaceOpenJPAEntityManagerFactory
-
getQueryResultCache
Description copied from interface:OpenJPAEntityManagerFactory
Access query result cache.- Specified by:
getQueryResultCache
in interfaceOpenJPAEntityManagerFactory
-
createEntityManager
- Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
createEntityManager
in interfaceOpenJPAEntityManagerFactory
- Specified by:
createEntityManager
in interfaceOpenJPAEntityManagerFactorySPI
-
createEntityManager
public OpenJPAEntityManagerSPI createEntityManager(jakarta.persistence.SynchronizationType synchronizationType) - Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
-
createEntityManager
Description copied from interface:OpenJPAEntityManagerFactory
Return an entity manager with the provided additional configuration settings. OpenJPA recognizes the following configuration settings in this method:- openjpa.ConnectionUsername
- openjpa.ConnectionPassword
- openjpa.ConnectionRetainMode
- openjpa.TransactionMode
- Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
createEntityManager
in interfaceOpenJPAEntityManagerFactory
- Specified by:
createEntityManager
in interfaceOpenJPAEntityManagerFactorySPI
-
createEntityManager
public OpenJPAEntityManagerSPI createEntityManager(jakarta.persistence.SynchronizationType synchronizationType, Map props) Creates and configures a entity manager with the given properties. The property keys in the given map can be either qualified or not.- Specified by:
createEntityManager
in interfacejakarta.persistence.EntityManagerFactory
- Returns:
- list of exceptions raised or empty list.
-
newEntityManagerImpl
Create a new entity manager around the given broker. -
addLifecycleListener
Description copied from interface:OpenJPAEntityManagerFactorySPI
Register a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener. The listener will be passed on to all new entity managers. See theorg.apache.openjpa.event
package for listener types.- Specified by:
addLifecycleListener
in interfaceOpenJPAEntityManagerFactory
- Specified by:
addLifecycleListener
in interfaceOpenJPAEntityManagerFactorySPI
-
removeLifecycleListener
Description copied from interface:OpenJPAEntityManagerFactorySPI
Remove a listener for lifecycle-related events.- Specified by:
removeLifecycleListener
in interfaceOpenJPAEntityManagerFactory
- Specified by:
removeLifecycleListener
in interfaceOpenJPAEntityManagerFactorySPI
-
addTransactionListener
Description copied from interface:OpenJPAEntityManagerFactorySPI
Register a listener for transaction-related events on the specified classes. The listener will be passed on to all new entity managers. See theorg.apache.openjpa.event
package for listener types.- Specified by:
addTransactionListener
in interfaceOpenJPAEntityManagerFactory
- Specified by:
addTransactionListener
in interfaceOpenJPAEntityManagerFactorySPI
-
removeTransactionListener
Description copied from interface:OpenJPAEntityManagerFactorySPI
Remove a listener for transaction-related events.- Specified by:
removeTransactionListener
in interfaceOpenJPAEntityManagerFactory
- Specified by:
removeTransactionListener
in interfaceOpenJPAEntityManagerFactorySPI
-
close
public void close() -
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfacejakarta.persistence.EntityManagerFactory
-
hashCode
public int hashCode() -
equals
-
getCache
public jakarta.persistence.Cache getCache()- Specified by:
getCache
in interfacejakarta.persistence.EntityManagerFactory
-
getCriteriaBuilder
Description copied from interface:OpenJPAEntityManagerFactory
Gets the QueryBuilder with OpenJPA-extended capabilities.- Specified by:
getCriteriaBuilder
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
getCriteriaBuilder
in interfaceOpenJPAEntityManagerFactory
-
getDynamicQueryBuilder
Description copied from interface:OpenJPAEntityManagerFactory
Gets a builder for dynamic queries.- Specified by:
getDynamicQueryBuilder
in interfaceOpenJPAEntityManagerFactory
-
getSupportedProperties
Description copied from interface:OpenJPAEntityManagerFactory
Get the properties supported by this runtime.- Specified by:
getSupportedProperties
in interfaceOpenJPAEntityManagerFactory
-
getMetamodel
- Specified by:
getMetamodel
in interfacejakarta.persistence.EntityManagerFactory
-
getPersistenceUnitUtil
public jakarta.persistence.PersistenceUnitUtil getPersistenceUnitUtil()- Specified by:
getPersistenceUnitUtil
in interfacejakarta.persistence.EntityManagerFactory
-
addNamedQuery
- Specified by:
addNamedQuery
in interfacejakarta.persistence.EntityManagerFactory
-
unwrap
- Specified by:
unwrap
in interfacejakarta.persistence.EntityManagerFactory
-
addNamedEntityGraph
public <T> void addNamedEntityGraph(String graphName, jakarta.persistence.EntityGraph<T> entityGraph) - Specified by:
addNamedEntityGraph
in interfacejakarta.persistence.EntityManagerFactory
-
getIdentifier
Get the identifier for the specified entity. If not managed by any of the em's in this PU or not persistence capable, return null.- Specified by:
getIdentifier
in interfacejakarta.persistence.PersistenceUnitUtil
-
isLoaded
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUnitUtil
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUtil
-
isLoaded
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUnitUtil
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUtil
-