Class EntityManagerFactoryImpl
- All Implemented Interfaces:
EntityManagerFactory, PersistenceUnitUtil, PersistenceUtil, Serializable, AutoCloseable, Closeable, OpenJPAEntityManagerFactory, OpenJPAEntityManagerFactorySPI
EntityManagerFactory that acts as a
facade to a BrokerFactory.- Author:
- Marc Prud'hommeaux
- See Also:
-
Field Summary
Fields inherited from interface OpenJPAEntityManagerFactory
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor provided for auto-instantiation.EntityManagerFactoryImpl(BrokerFactory factory) Supply delegate on construction. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLifecycleListener(Object listener, Class... classes) Register a listener for lifecycle-related events on the specified classes.<T> voidaddNamedEntityGraph(String graphName, EntityGraph<T> entityGraph) voidaddNamedQuery(String name, Query query) voidaddTransactionListener(Object listener) Register a listener for transaction-related events on the specified classes.<R> RcallInTransaction(Function<EntityManager, R> work) voidclose()createEntityManager(SynchronizationType synchronizationType) createEntityManager(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.booleanDelegate.getCache()<T> Class<? extends T> getClass(T entity) 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.getName()<E> Map<String, EntityGraph<? extends E>> getNamedEntityGraphs(Class<E> entityType) <R> Map<String, TypedQueryReference<R>> getNamedQueries(Class<R> resultType) Return the named queries whose declared result type is assignable to the given result type.Return properties describing this entity manager factory 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.getVersion(Object entity) inthashCode()booleanisInstance(Object entity, Class<?> entityClass) <E> booleanbooleanbooleanbooleanisOpen()<E> voidvoidvoidprotected EntityManagerImplnewEntityManagerImpl(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.voidremoveLifecycleListener(Object listener) Remove a listener for lifecycle-related events.voidremoveTransactionListener(Object listener) Remove a listener for transaction-related events.voidvoidsetBrokerFactory(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:OpenJPAEntityManagerFactorySPIReturn the configuration for this factory.- Specified by:
getConfigurationin interfaceOpenJPAEntityManagerFactory- Specified by:
getConfigurationin interfaceOpenJPAEntityManagerFactorySPI
-
getProperties
Description copied from interface:OpenJPAEntityManagerFactoryReturn properties describing this entity manager factory runtime. Entity-manager settings are available fromEntityManager.getProperties()instead; returned runtime values are not guaranteed to be configuration inputs.- Specified by:
getPropertiesin interfaceEntityManagerFactory- Specified by:
getPropertiesin interfaceOpenJPAEntityManagerFactory
-
putUserObject
Description copied from interface:OpenJPAEntityManagerFactoryPut the specified key-value pair into the map of user objects.- Specified by:
putUserObjectin interfaceOpenJPAEntityManagerFactory
-
getUserObject
Description copied from interface:OpenJPAEntityManagerFactoryGet the value for the specified key from the map of user objects.- Specified by:
getUserObjectin interfaceOpenJPAEntityManagerFactory
-
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
Description copied from interface:OpenJPAEntityManagerFactoryAccess a named level 2 store cache.- Specified by:
getStoreCachein interfaceOpenJPAEntityManagerFactory
-
getQueryResultCache
Description copied from interface:OpenJPAEntityManagerFactoryAccess query result cache.- Specified by:
getQueryResultCachein interfaceOpenJPAEntityManagerFactory
-
createEntityManager
- Specified by:
createEntityManagerin interfaceEntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactorySPI
-
createEntityManager
- Specified by:
createEntityManagerin interfaceEntityManagerFactory
-
createEntityManager
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 interfaceEntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactory- Specified by:
createEntityManagerin interfaceOpenJPAEntityManagerFactorySPI
-
createEntityManager
public OpenJPAEntityManagerSPI createEntityManager(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:
createEntityManagerin interfaceEntityManagerFactory- Returns:
- list of exceptions raised or empty list.
-
newEntityManagerImpl
Create a new entity manager around the given broker. -
addLifecycleListener
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
Description copied from interface:OpenJPAEntityManagerFactorySPIRemove a listener for lifecycle-related events.- Specified by:
removeLifecycleListenerin interfaceOpenJPAEntityManagerFactory- Specified by:
removeLifecycleListenerin interfaceOpenJPAEntityManagerFactorySPI
-
addTransactionListener
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
Description copied from interface:OpenJPAEntityManagerFactorySPIRemove a listener for transaction-related events.- Specified by:
removeTransactionListenerin interfaceOpenJPAEntityManagerFactory- Specified by:
removeTransactionListenerin interfaceOpenJPAEntityManagerFactorySPI
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceEntityManagerFactory
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceEntityManagerFactory
-
hashCode
-
equals
-
getCache
- Specified by:
getCachein interfaceEntityManagerFactory
-
getCriteriaBuilder
Description copied from interface:OpenJPAEntityManagerFactoryGets the QueryBuilder with OpenJPA-extended capabilities.- Specified by:
getCriteriaBuilderin interfaceEntityManagerFactory- Specified by:
getCriteriaBuilderin interfaceOpenJPAEntityManagerFactory
-
getDynamicQueryBuilder
Description copied from interface:OpenJPAEntityManagerFactoryGets a builder for dynamic queries.- Specified by:
getDynamicQueryBuilderin interfaceOpenJPAEntityManagerFactory
-
getSupportedProperties
Description copied from interface:OpenJPAEntityManagerFactoryGet the properties supported by this runtime.- Specified by:
getSupportedPropertiesin interfaceOpenJPAEntityManagerFactory
-
getMetamodel
- Specified by:
getMetamodelin interfaceEntityManagerFactory
-
getName
- Specified by:
getNamein interfaceEntityManagerFactory
-
getPersistenceUnitUtil
- Specified by:
getPersistenceUnitUtilin interfaceEntityManagerFactory
-
addNamedQuery
- Specified by:
addNamedQueryin interfaceEntityManagerFactory
-
unwrap
- Specified by:
unwrapin interfaceEntityManagerFactory
-
addNamedEntityGraph
- Specified by:
addNamedEntityGraphin interfaceEntityManagerFactory
-
getNamedEntityGraphs
- Specified by:
getNamedEntityGraphsin interfaceEntityManagerFactory
-
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:
getIdentifierin interfacePersistenceUnitUtil
-
isLoaded
- Specified by:
isLoadedin interfacePersistenceUnitUtil- Specified by:
isLoadedin interfacePersistenceUtil
-
isLoaded
- Specified by:
isLoadedin interfacePersistenceUnitUtil- Specified by:
isLoadedin interfacePersistenceUtil
-
isLoaded
- Specified by:
isLoadedin interfacePersistenceUnitUtil
-
getSchemaManager
- Specified by:
getSchemaManagerin interfaceEntityManagerFactory
-
callInTransaction
- Specified by:
callInTransactionin interfaceEntityManagerFactory
-
runInTransaction
- Specified by:
runInTransactionin interfaceEntityManagerFactory
-
getClass
- Specified by:
getClassin interfacePersistenceUnitUtil
-
getNamedQueries
Return the named queries whose declared result type is assignable to the given result type.The declared result type of a query is
QueryMetaData.getResultType()if set, otherwiseQueryMetaData.getCandidateType()- managed result classes are recorded as the candidate type by the metadata parsers, exactly ascreateNamedQuery(name, resultClass)would do. Named queries without any declared result type (i.e. a JPQL@NamedQuerywithoutresultClass, or a query declared in XML - the bundled orm_3_2 schema does not allow aresult-classattribute onnamed-query) are never returned, for any result type includingObject.class, because their result type cannot be proven.The hints carried by the returned references are the hints of the named query, including the OpenJPA specific hints synthesized by the parsers (e.g.
openjpa.FetchPlan.ReadLockModederived from@NamedQuery.lockMode()); these are exactly the hints replayed bycreateNamedQuery.A freshly computed, modifiable map is returned on every call; it is not a live view of the metadata repository.
- Specified by:
getNamedQueriesin interfaceEntityManagerFactory
-
getTransactionType
- Specified by:
getTransactionTypein interfaceEntityManagerFactory
-
getVersion
- Specified by:
getVersionin interfacePersistenceUnitUtil
-
isInstance
- Specified by:
isInstancein interfacePersistenceUnitUtil
-
load
- Specified by:
loadin interfacePersistenceUnitUtil
-
load
- Specified by:
loadin interfacePersistenceUnitUtil
-
load
- Specified by:
loadin interfacePersistenceUnitUtil
-