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 ofEntityManagerFactory
that 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 void
addLifecycleListener(java.lang.Object listener, java.lang.Class... classes)
Register a listener for lifecycle-related events on the specified classes.<T> void
addNamedEntityGraph(java.lang.String graphName, jakarta.persistence.EntityGraph<T> entityGraph)
void
addNamedQuery(java.lang.String name, jakarta.persistence.Query query)
void
addTransactionListener(java.lang.Object listener)
Register a listener for transaction-related events on the specified classes.void
close()
OpenJPAEntityManagerSPI
createEntityManager()
OpenJPAEntityManagerSPI
createEntityManager(jakarta.persistence.SynchronizationType synchronizationType)
OpenJPAEntityManagerSPI
createEntityManager(jakarta.persistence.SynchronizationType synchronizationType, java.util.Map props)
Creates and configures a entity manager with the given properties.OpenJPAEntityManagerSPI
createEntityManager(java.util.Map props)
Return an entity manager with the provided additional configuration settings.boolean
equals(java.lang.Object other)
BrokerFactory
getBrokerFactory()
Delegate.jakarta.persistence.Cache
getCache()
OpenJPAConfiguration
getConfiguration()
Return the configuration for this factory.OpenJPACriteriaBuilder
getCriteriaBuilder()
Gets the QueryBuilder with OpenJPA-extended capabilities.OpenJPAQueryBuilder
getDynamicQueryBuilder()
Gets a builder for dynamic queries.java.lang.Object
getIdentifier(java.lang.Object entity)
Get the identifier for the specified entity.MetamodelImpl
getMetamodel()
jakarta.persistence.PersistenceUnitUtil
getPersistenceUnitUtil()
java.util.Map<java.lang.String,java.lang.Object>
getProperties()
Return properties describing this runtime.QueryResultCache
getQueryResultCache()
Access query result cache.StoreCache
getStoreCache()
Access the level 2 store cache.StoreCache
getStoreCache(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.Object
getUserObject(java.lang.Object key)
Get the value for the specified key from the map of user objects.int
hashCode()
boolean
isLoaded(java.lang.Object entity)
boolean
isLoaded(java.lang.Object entity, java.lang.String attribute)
boolean
isOpen()
protected EntityManagerImpl
newEntityManagerImpl(Broker broker)
Create a new entity manager around the given broker.java.lang.Object
putUserObject(java.lang.Object key, java.lang.Object val)
Put the specified key-value pair into the map of user objects.void
removeLifecycleListener(java.lang.Object listener)
Remove a listener for lifecycle-related events.void
removeTransactionListener(java.lang.Object listener)
Remove a listener for transaction-related events.void
setBrokerFactory(BrokerFactory factory)
Delegate must be provided before use.<T> T
unwrap(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:OpenJPAEntityManagerFactorySPI
Return the configuration for this factory.- Specified by:
getConfiguration
in interfaceOpenJPAEntityManagerFactory
- Specified by:
getConfiguration
in interfaceOpenJPAEntityManagerFactorySPI
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Description copied from interface:OpenJPAEntityManagerFactory
Return properties describing this runtime.- Specified by:
getProperties
in interfacejakarta.persistence.EntityManagerFactory
- Specified by:
getProperties
in interfaceOpenJPAEntityManagerFactory
-
putUserObject
public java.lang.Object putUserObject(java.lang.Object key, java.lang.Object val)
Description copied from interface:OpenJPAEntityManagerFactory
Put the specified key-value pair into the map of user objects.- Specified by:
putUserObject
in interfaceOpenJPAEntityManagerFactory
-
getUserObject
public java.lang.Object getUserObject(java.lang.Object key)
Description copied from interface:OpenJPAEntityManagerFactory
Get the value for the specified key from the map of user objects.- Specified by:
getUserObject
in interfaceOpenJPAEntityManagerFactory
-
getStoreCache
public StoreCache 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
public StoreCache getStoreCache(java.lang.String cacheName)
Description copied from interface:OpenJPAEntityManagerFactory
Access a named level 2 store cache.- Specified by:
getStoreCache
in interfaceOpenJPAEntityManagerFactory
-
getQueryResultCache
public QueryResultCache getQueryResultCache()
Description copied from interface:OpenJPAEntityManagerFactory
Access query result cache.- Specified by:
getQueryResultCache
in interfaceOpenJPAEntityManagerFactory
-
createEntityManager
public OpenJPAEntityManagerSPI 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
public OpenJPAEntityManagerSPI createEntityManager(java.util.Map props)
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, 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:
createEntityManager
in 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: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
public void removeLifecycleListener(java.lang.Object listener)
Description copied from interface:OpenJPAEntityManagerFactorySPI
Remove a listener for lifecycle-related events.- Specified by:
removeLifecycleListener
in interfaceOpenJPAEntityManagerFactory
- Specified by:
removeLifecycleListener
in interfaceOpenJPAEntityManagerFactorySPI
-
addTransactionListener
public void addTransactionListener(java.lang.Object listener)
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
public void removeTransactionListener(java.lang.Object listener)
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()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
getCache
public jakarta.persistence.Cache getCache()
- Specified by:
getCache
in interfacejakarta.persistence.EntityManagerFactory
-
getCriteriaBuilder
public OpenJPACriteriaBuilder 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
public OpenJPAQueryBuilder getDynamicQueryBuilder()
Description copied from interface:OpenJPAEntityManagerFactory
Gets a builder for dynamic queries.- Specified by:
getDynamicQueryBuilder
in interfaceOpenJPAEntityManagerFactory
-
getSupportedProperties
public java.util.Set<java.lang.String> getSupportedProperties()
Description copied from interface:OpenJPAEntityManagerFactory
Get the properties supported by this runtime.- Specified by:
getSupportedProperties
in interfaceOpenJPAEntityManagerFactory
-
getMetamodel
public MetamodelImpl getMetamodel()
- Specified by:
getMetamodel
in interfacejakarta.persistence.EntityManagerFactory
-
getPersistenceUnitUtil
public jakarta.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
- Specified by:
getPersistenceUnitUtil
in interfacejakarta.persistence.EntityManagerFactory
-
addNamedQuery
public void addNamedQuery(java.lang.String name, jakarta.persistence.Query query)
- Specified by:
addNamedQuery
in interfacejakarta.persistence.EntityManagerFactory
-
unwrap
public <T> T unwrap(java.lang.Class<T> cls)
- Specified by:
unwrap
in interfacejakarta.persistence.EntityManagerFactory
-
addNamedEntityGraph
public <T> void addNamedEntityGraph(java.lang.String graphName, jakarta.persistence.EntityGraph<T> entityGraph)
- Specified by:
addNamedEntityGraph
in 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:
getIdentifier
in interfacejakarta.persistence.PersistenceUnitUtil
-
isLoaded
public boolean isLoaded(java.lang.Object entity)
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUnitUtil
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUtil
-
isLoaded
public boolean isLoaded(java.lang.Object entity, java.lang.String attribute)
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUnitUtil
- Specified by:
isLoaded
in interfacejakarta.persistence.PersistenceUtil
-
-