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,java.io.Serializable,Closeable,OpenJPAEntityManagerFactory,OpenJPAEntityManagerFactorySPI
public class EntityManagerFactoryImpl extends java.lang.Object implements OpenJPAEntityManagerFactory, OpenJPAEntityManagerFactorySPI, Closeable, jakarta.persistence.PersistenceUnitUtil
Implementation ofEntityManagerFactorythat acts as a facade to aBrokerFactory.- Author:
- Marc Prud'hommeaux
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.openjpa.persistence.OpenJPAEntityManagerFactory
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS
-
-
Constructor Summary
Constructors Constructor Description EntityManagerFactoryImpl()Default constructor provided for auto-instantiation.EntityManagerFactoryImpl(BrokerFactory factory)Supply delegate on construction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLifecycleListener(java.lang.Object listener, java.lang.Class... classes)Register a listener for lifecycle-related events on the specified classes.<T> voidaddNamedEntityGraph(java.lang.String graphName, jakarta.persistence.EntityGraph<T> entityGraph)voidaddNamedQuery(java.lang.String name, jakarta.persistence.Query query)voidaddTransactionListener(java.lang.Object listener)Register a listener for transaction-related events on the specified classes.voidclose()OpenJPAEntityManagerSPIcreateEntityManager()OpenJPAEntityManagerSPIcreateEntityManager(jakarta.persistence.SynchronizationType synchronizationType)OpenJPAEntityManagerSPIcreateEntityManager(jakarta.persistence.SynchronizationType synchronizationType, java.util.Map props)Creates and configures a entity manager with the given properties.OpenJPAEntityManagerSPIcreateEntityManager(java.util.Map props)Return an entity manager with the provided additional configuration settings.booleanequals(java.lang.Object other)BrokerFactorygetBrokerFactory()Delegate.jakarta.persistence.CachegetCache()OpenJPAConfigurationgetConfiguration()Return the configuration for this factory.OpenJPACriteriaBuildergetCriteriaBuilder()Gets the QueryBuilder with OpenJPA-extended capabilities.OpenJPAQueryBuildergetDynamicQueryBuilder()Gets a builder for dynamic queries.java.lang.ObjectgetIdentifier(java.lang.Object entity)Get the identifier for the specified entity.MetamodelImplgetMetamodel()jakarta.persistence.PersistenceUnitUtilgetPersistenceUnitUtil()java.util.Map<java.lang.String,java.lang.Object>getProperties()Return properties describing this runtime.QueryResultCachegetQueryResultCache()Access query result cache.StoreCachegetStoreCache()Access the level 2 store cache.StoreCachegetStoreCache(java.lang.String cacheName)Access a named level 2 store cache.java.util.Set<java.lang.String>getSupportedProperties()Get the properties supported by this runtime.java.lang.ObjectgetUserObject(java.lang.Object key)Get the value for the specified key from the map of user objects.inthashCode()booleanisLoaded(java.lang.Object entity)booleanisLoaded(java.lang.Object entity, java.lang.String attribute)booleanisOpen()protected EntityManagerImplnewEntityManagerImpl(Broker broker)Create a new entity manager around the given broker.java.lang.ObjectputUserObject(java.lang.Object key, java.lang.Object val)Put the specified key-value pair into the map of user objects.voidremoveLifecycleListener(java.lang.Object listener)Remove a listener for lifecycle-related events.voidremoveTransactionListener(java.lang.Object listener)Remove a listener for transaction-related events.voidsetBrokerFactory(BrokerFactory factory)Delegate must be provided before use.<T> Tunwrap(java.lang.Class<T> cls)
-
-
-
Constructor Detail
-
EntityManagerFactoryImpl
public EntityManagerFactoryImpl()
Default constructor provided for auto-instantiation.
-
EntityManagerFactoryImpl
public EntityManagerFactoryImpl(BrokerFactory factory)
Supply delegate on construction.
-
-
Method Detail
-
getBrokerFactory
public BrokerFactory getBrokerFactory()
Delegate.
-
setBrokerFactory
public void setBrokerFactory(BrokerFactory factory)
Delegate must be provided before use.
-
getConfiguration
public OpenJPAConfiguration getConfiguration()
Description copied from interface:OpenJPAEntityManagerFactorySPIReturn the configuration for this factory.- Specified by:
getConfigurationin interfaceOpenJPAEntityManagerFactory- Specified by:
getConfigurationin interfaceOpenJPAEntityManagerFactorySPI
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Description copied from interface:OpenJPAEntityManagerFactoryReturn properties describing this runtime.- Specified by:
getPropertiesin interfacejakarta.persistence.EntityManagerFactory- Specified by:
getPropertiesin interfaceOpenJPAEntityManagerFactory
-
putUserObject
public java.lang.Object putUserObject(java.lang.Object key, java.lang.Object val)Description copied from interface:OpenJPAEntityManagerFactoryPut the specified key-value pair into the map of user objects.- Specified by:
putUserObjectin interfaceOpenJPAEntityManagerFactory
-
getUserObject
public java.lang.Object getUserObject(java.lang.Object key)
Description copied from interface:OpenJPAEntityManagerFactoryGet the value for the specified key from the map of user objects.- Specified by:
getUserObjectin interfaceOpenJPAEntityManagerFactory
-
getStoreCache
public StoreCache getStoreCache()
Description copied from interface:OpenJPAEntityManagerFactoryAccess the level 2 store cache. This cache acts as a proxy to all named caches.- Specified by:
getStoreCachein interfaceOpenJPAEntityManagerFactory
-
getStoreCache
public StoreCache getStoreCache(java.lang.String cacheName)
Description copied from interface:OpenJPAEntityManagerFactoryAccess a named level 2 store cache.- Specified by:
getStoreCachein interfaceOpenJPAEntityManagerFactory
-
getQueryResultCache
public QueryResultCache getQueryResultCache()
Description copied from interface:OpenJPAEntityManagerFactoryAccess query result cache.- Specified by:
getQueryResultCachein interfaceOpenJPAEntityManagerFactory
-
createEntityManager
public OpenJPAEntityManagerSPI createEntityManager()
- Specified by:
createEntityManagerin interfacejakarta.persistence.EntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactorySPI
-
createEntityManager
public OpenJPAEntityManagerSPI createEntityManager(jakarta.persistence.SynchronizationType synchronizationType)
- Specified by:
createEntityManagerin interfacejakarta.persistence.EntityManagerFactory
-
createEntityManager
public OpenJPAEntityManagerSPI createEntityManager(java.util.Map props)
Description copied from interface:OpenJPAEntityManagerFactoryReturn 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:
createEntityManagerin interfacejakarta.persistence.EntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactorySPI
-
createEntityManager
public OpenJPAEntityManagerSPI createEntityManager(jakarta.persistence.SynchronizationType synchronizationType, java.util.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:
createEntityManagerin interfacejakarta.persistence.EntityManagerFactory- Returns:
- list of exceptions raised or empty list.
-
newEntityManagerImpl
protected EntityManagerImpl newEntityManagerImpl(Broker broker)
Create a new entity manager around the given broker.
-
addLifecycleListener
public void addLifecycleListener(java.lang.Object listener, java.lang.Class... classes)Description copied from interface:OpenJPAEntityManagerFactorySPIRegister 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.eventpackage for listener types.- Specified by:
addLifecycleListenerin interfaceOpenJPAEntityManagerFactory- Specified by:
addLifecycleListenerin interfaceOpenJPAEntityManagerFactorySPI
-
removeLifecycleListener
public void removeLifecycleListener(java.lang.Object listener)
Description copied from interface:OpenJPAEntityManagerFactorySPIRemove a listener for lifecycle-related events.- Specified by:
removeLifecycleListenerin interfaceOpenJPAEntityManagerFactory- Specified by:
removeLifecycleListenerin interfaceOpenJPAEntityManagerFactorySPI
-
addTransactionListener
public void addTransactionListener(java.lang.Object listener)
Description copied from interface:OpenJPAEntityManagerFactorySPIRegister 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.eventpackage for listener types.- Specified by:
addTransactionListenerin interfaceOpenJPAEntityManagerFactory- Specified by:
addTransactionListenerin interfaceOpenJPAEntityManagerFactorySPI
-
removeTransactionListener
public void removeTransactionListener(java.lang.Object listener)
Description copied from interface:OpenJPAEntityManagerFactorySPIRemove a listener for transaction-related events.- Specified by:
removeTransactionListenerin interfaceOpenJPAEntityManagerFactory- Specified by:
removeTransactionListenerin interfaceOpenJPAEntityManagerFactorySPI
-
close
public void close()
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejakarta.persistence.EntityManagerFactory
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
getCache
public jakarta.persistence.Cache getCache()
- Specified by:
getCachein interfacejakarta.persistence.EntityManagerFactory
-
getCriteriaBuilder
public OpenJPACriteriaBuilder getCriteriaBuilder()
Description copied from interface:OpenJPAEntityManagerFactoryGets the QueryBuilder with OpenJPA-extended capabilities.- Specified by:
getCriteriaBuilderin interfacejakarta.persistence.EntityManagerFactory- Specified by:
getCriteriaBuilderin interfaceOpenJPAEntityManagerFactory
-
getDynamicQueryBuilder
public OpenJPAQueryBuilder getDynamicQueryBuilder()
Description copied from interface:OpenJPAEntityManagerFactoryGets a builder for dynamic queries.- Specified by:
getDynamicQueryBuilderin interfaceOpenJPAEntityManagerFactory
-
getSupportedProperties
public java.util.Set<java.lang.String> getSupportedProperties()
Description copied from interface:OpenJPAEntityManagerFactoryGet the properties supported by this runtime.- Specified by:
getSupportedPropertiesin interfaceOpenJPAEntityManagerFactory
-
getMetamodel
public MetamodelImpl getMetamodel()
- Specified by:
getMetamodelin interfacejakarta.persistence.EntityManagerFactory
-
getPersistenceUnitUtil
public jakarta.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
- Specified by:
getPersistenceUnitUtilin interfacejakarta.persistence.EntityManagerFactory
-
addNamedQuery
public void addNamedQuery(java.lang.String name, jakarta.persistence.Query query)- Specified by:
addNamedQueryin interfacejakarta.persistence.EntityManagerFactory
-
unwrap
public <T> T unwrap(java.lang.Class<T> cls)
- Specified by:
unwrapin interfacejakarta.persistence.EntityManagerFactory
-
addNamedEntityGraph
public <T> void addNamedEntityGraph(java.lang.String graphName, jakarta.persistence.EntityGraph<T> entityGraph)- Specified by:
addNamedEntityGraphin interfacejakarta.persistence.EntityManagerFactory
-
getIdentifier
public java.lang.Object getIdentifier(java.lang.Object entity)
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:
getIdentifierin interfacejakarta.persistence.PersistenceUnitUtil
-
isLoaded
public boolean isLoaded(java.lang.Object entity)
- Specified by:
isLoadedin interfacejakarta.persistence.PersistenceUnitUtil- Specified by:
isLoadedin interfacejakarta.persistence.PersistenceUtil
-
isLoaded
public boolean isLoaded(java.lang.Object entity, java.lang.String attribute)- Specified by:
isLoadedin interfacejakarta.persistence.PersistenceUnitUtil- Specified by:
isLoadedin interfacejakarta.persistence.PersistenceUtil
-
-