Purpose: Provides the implementation for the EntityManager Factory.
Description: This class will store a reference to the active ServerSession. When a request is made for an EntityManager an new EntityManager is created with the ServerSession and returned. The primary consumer of these EntityManager is assumed to be either the Container. There is one EntityManagerFactory per deployment.
jakarta.persistence.EntityManager , org.eclipse.persistence.jpa.JpaEntityManager , org.eclipse.persistence.jpa.JpaEntityManagerFactory
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | beginEarlyTransaction
Default join existing transaction property, allows reading through write connection. |
| protected boolean | closeOnCommit
Default property to avoid resuming unit of work if going to be closed on commit anyway. |
| protected UnitOfWork. | commitOrder
Order updates by id to avoid potential deadlocks. |
| protected boolean | |
| protected String | flushClearCache
Default FlashClearCache mode to be used. |
| protected FlushModeType | flushMode
Default property, allows flush before query to be avoided. |
| protected boolean | isOpen
Stores if closed has been called. |
| protected Cache | myCache
Reference to Cache Interface. |
| protected JpaEntityManagerFactory | owner
Pointer to the EntityManagerFactoryImpl that created me |
| protected boolean | persistOnCommit
Default property to avoid discover new objects in unit of work if application always uses persist. |
| protected Map | properties
Persistence unit properties from create factory. |
| protected ReferenceMode | referenceMode
Default property, allows weak unit of work references. |
| protected volatile AbstractSession | session
Reference to the ServerSession for this deployment. |
| protected EntityManagerSetupImpl | setupImpl
EntityManagerSetupImpl that deployed this factory. |
| protected boolean | shouldValidateExistence
Default to determine if does-exist should be performed on persist. |
| protected static final Set | supportedNonServerSessionProperties
INTERNAL: The following properties passed to createEMF cached and processed on the emf directly. |
| Access | Constructor and Description |
|---|---|
| public | EntityManagerFactoryDelegate(AbstractSession databaseSession, JpaEntityManagerFactory owner)
Will return an instance of the Factory. |
| public | EntityManagerFactoryDelegate(EntityManagerSetupImpl setupImpl, Map<K, V> properties, JpaEntityManagerFactory owner)
|
| public | EntityManagerFactoryDelegate(String persistenceUnitName, Map<String, Object> properties, List<ClassDescriptor> descriptors, JpaEntityManagerFactory owner)
Create a dynamic persistence unit which does not use the persistence.xml. |
| Modifier and Type | Method and Description |
|---|---|
| public <T> void | addNamedEntityGraph(String
name for the entity graph graphName, EntityGraph<T> entity graph entityGraph)Implements jakarta. |
| public void | addNamedQuery(String
name for the query name, Query Query, TypedQuery, or StoredProcedureQuery object query)Implements jakarta. createNamedQuery or
createNamedStoredProcedureQuery method.
|
| public synchronized void | close()
Implements jakarta. |
| public EntityManager | createEntityManager()
Implements jakarta. |
| public EntityManager | createEntityManager(Map<K, V>
properties for entity manager properties)Implements jakarta. |
| public EntityManager | createEntityManager(SynchronizationType
how and when the entity manager should be
synchronized with the current JTA transaction synchronizationType, Map<K, V> properties for entity manager map)Implements jakarta. EntityManager with the
specified synchronization type and map of properties.
|
| public EntityManager | createEntityManager(SynchronizationType
how and when the entity manager should be
synchronized with the current JTA transaction synchronizationType)Implements jakarta. EntityManager with the
specified synchronization type.
|
| protected EntityManagerImpl | |
| protected void | finalize()
Overrides java. |
| public AbstractSession | getAbstractSession()
INTERNAL: Returns the ServerSession that the Factory will be using and initializes it if it is not available. |
| public boolean | getBeginEarlyTransaction()
Return default join existing transaction property, allows reading through write connection. |
| public Cache | Returns: instance of theCache interfaceImplements jakarta. |
| public boolean | getCloseOnCommit()
Return default property to avoid resuming unit of work if going to be closed on commit anyway. |
| public UnitOfWork. | getCommitOrder()
Return if updates should be ordered by primary key, to avoid potential database deadlocks. |
| public boolean | getCommitWithoutPersistRules()
Return default property to avoid discover new objects in unit of work if application always uses persist. |
| public CriteriaBuilder | getCriteriaBuilder()
Implements jakarta. CriteriaBuilder for the creation of
CriteriaQuery objects.
|
| public DatabaseSessionImpl | getDatabaseSession()
Implements org. |
| public String | |
| public FlushModeType | |
| public Object | Returns: id of the entityentity instance entity)Implements jakarta. |
| public Metamodel | Returns: Metamodel instanceImplements jakarta. |
| public JpaEntityManagerFactory | |
| public PersistenceUnitUtil | Returns: PersistenceUnitUtil interfaceImplements jakarta. |
| public boolean | getPersistOnCommit()
Return default property to avoid discover new objects in unit of work if application always uses persist. |
| public Map | getProperties()
Implements jakarta. |
| public Object | getProperty(String name)
The method return user defined property passed in from EntityManagerFactory. |
| public ReferenceMode | |
| public ServerSession | getServerSession()
Implements org. |
| public SessionBroker | getSessionBroker()
Implements org. |
| public EntityManagerSetupImpl | |
| public boolean | Returns: false if entity's state has not been loaded or if the attribute state has not been loaded, otherwise truecontaining the attribute entity, String name of attribute whose load state is to be determined attributeName)Implements jakarta. |
| public boolean | Returns: false if the entity has not been loaded, else true.whose load state is to be determined entity)Implements jakarta. |
| public boolean | isOpen()
Implements jakarta. |
| protected void | |
| public void | refreshMetadata(Map<K, V> properties)
Implements org. |
| public void | setBeginEarlyTransaction(boolean beginEarlyTransaction)
Set default join existing transaction property, allows reading through write connection. |
| public void | setCloseOnCommit(boolean closeOnCommit)
Set default property to avoid resuming unit of work if going to be closed on commit anyway. |
| public void | setCommitOrder(UnitOfWork.
Set update ordering by primary key, to avoid potential database deadlocks. |
| public void | setCommitWithoutPersistRules(boolean commitWithoutPersistRules)
Set default property to avoid discover new objects in unit of work if application always uses persist. |
| public void | |
| public void | |
| public void | setMetamodel(Metamodel aMetamodel)
INTERNAL: Convenience function to allow us to reset the Metamodel in the possible case that we want to regenerate it. |
| public void | setPersistOnCommit(boolean persistOnCommit)
Set default property to avoid discover new objects in unit of work if application always uses persist. |
| public void | setReferenceMode(ReferenceMode referenceMode)
Set default property, allows weak unit of work references. |
| public void | setShouldValidateExistence(boolean shouldValidateExistence)
Set the default to determine if does-exist should be performed on persist. |
| public boolean | shouldValidateExistence()
Return the default to determine if does-exist should be performed on persist. |
| public EntityManagerFactoryDelegate | unwrap()
Implements org. |
| public <T> T | unwrap(Class<T>
the class of the object to be returned. This is
normally either the underlying EntityManagerFactory
implementation class or an interface that it implements. cls)Implements jakarta. |
| protected void |
| beginEarlyTransaction | back to summary |
|---|---|
| protected boolean beginEarlyTransaction Default join existing transaction property, allows reading through write connection. | |
| closeOnCommit | back to summary |
|---|---|
| protected boolean closeOnCommit Default property to avoid resuming unit of work if going to be closed on commit anyway. | |
| commitOrder | back to summary |
|---|---|
| protected UnitOfWork. Order updates by id to avoid potential deadlocks. Default is true. | |
| commitWithoutPersistRules | back to summary |
|---|---|
| protected boolean commitWithoutPersistRules | |
| flushClearCache | back to summary |
|---|---|
| protected String flushClearCache Default FlashClearCache mode to be used. Relevant only in case call to flush method followed by call to clear method. | |
| flushMode | back to summary |
|---|---|
| protected FlushModeType flushMode Default property, allows flush before query to be avoided. | |
| isOpen | back to summary |
|---|---|
| protected boolean isOpen Stores if closed has been called. | |
| myCache | back to summary |
|---|---|
| protected Cache myCache Reference to Cache Interface. | |
| owner | back to summary |
|---|---|
| protected JpaEntityManagerFactory owner Pointer to the EntityManagerFactoryImpl that created me | |
| persistOnCommit | back to summary |
|---|---|
| protected boolean persistOnCommit Default property to avoid discover new objects in unit of work if application always uses persist. | |
| properties | back to summary |
|---|---|
| protected Map<K, V> properties Persistence unit properties from create factory. | |
| referenceMode | back to summary |
|---|---|
| protected ReferenceMode referenceMode Default property, allows weak unit of work references. | |
| session | back to summary |
|---|---|
| protected volatile AbstractSession session Reference to the ServerSession for this deployment. | |
| setupImpl | back to summary |
|---|---|
| protected EntityManagerSetupImpl setupImpl EntityManagerSetupImpl that deployed this factory. | |
| shouldValidateExistence | back to summary |
|---|---|
| protected boolean shouldValidateExistence Default to determine if does-exist should be performed on persist. | |
| supportedNonServerSessionProperties | back to summary |
|---|---|
| protected static final Set<String> supportedNonServerSessionProperties INTERNAL: The following properties passed to createEMF cached and processed on the emf directly. None of these properties processed during predeploy or deploy. | |
| EntityManagerFactoryDelegate | back to summary |
|---|---|
| public EntityManagerFactoryDelegate(AbstractSession databaseSession, JpaEntityManagerFactory owner) Will return an instance of the Factory. Should only be called by EclipseLink. | |
| EntityManagerFactoryDelegate | back to summary |
|---|---|
| public EntityManagerFactoryDelegate(EntityManagerSetupImpl setupImpl, Map<K, V> properties, JpaEntityManagerFactory owner) | |
| EntityManagerFactoryDelegate | back to summary |
|---|---|
| public EntityManagerFactoryDelegate(String persistenceUnitName, Map<String, Object> properties, List<ClassDescriptor> descriptors, JpaEntityManagerFactory owner) Create a dynamic persistence unit which does not use the persistence.xml. Instead all configuration is driven from the provided persistence unit properties and descriptors. | |
| addNamedEntityGraph | back to summary |
|---|---|
| public <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph) Implements jakarta. Doc from jakarta. Add a named copy of the EntityGraph to the EntityManagerFactory. If an entity graph with the same name already exists, it is replaced.
| |
| addNamedQuery | back to summary |
|---|---|
| public void addNamedQuery(String name, Query query) Implements jakarta. Doc from jakarta. Define the query, typed query, or stored procedure query as
a named query such that future query objects can be created
from it using the Any configuration of the query object (except for actual parameter binding) in effect when the named query is added is retained as part of the named query definition. This includes configuration information such as max results, hints, flush mode, lock mode, result set mapping information, and information about stored procedure parameters. When the query is executed, information that can be set
by means of the query APIs can be overridden. Information
that is overridden does not affect the named query as
registered with the entity manager factory, and thus does
not affect subsequent query objects created from it by
means of the If a named query of the same name has been previously defined, either statically via metadata or via this method, that query definition is replaced. | |
| close | back to summary |
|---|---|
| public synchronized void close() Implements jakarta. Closes this factory, releasing any resources that might be held by this
factory. After invoking this method, all methods on the instance will
throw an
| |
| createEntityManager | back to summary |
|---|---|
| public EntityManager createEntityManager() Implements jakarta. PUBLIC: Returns an EntityManager for this deployment.
| |
| createEntityManager | back to summary |
|---|---|
| public EntityManager createEntityManager(Map<K, V> properties) Implements jakarta. PUBLIC: Returns an EntityManager for this deployment.
| |
| createEntityManager | back to summary |
|---|---|
| public EntityManager createEntityManager(SynchronizationType synchronizationType, Map<K, V> map) Implements jakarta. Doc from jakarta. Create a new JTA application-managed
| |
| createEntityManager | back to summary |
|---|---|
| public EntityManager createEntityManager(SynchronizationType synchronizationType) Implements jakarta. Doc from jakarta. Create a new JTA application-managed
| |
| createEntityManagerImpl | back to summary |
|---|---|
| protected EntityManagerImpl createEntityManagerImpl(Map<K, V> properties, SynchronizationType syncType) | |
| finalize | back to summary |
|---|---|
| protected void finalize() throws Throwable Overrides java. Doc from java. Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the
When running in a Java virtual machine in which finalization has been
disabled or removed, the garbage collector will never call
The general contract of
The
The Java programming language does not guarantee which thread will
invoke the
After the
The
Any exception thrown by the | |
| getAbstractSession | back to summary |
|---|---|
| public AbstractSession getAbstractSession() INTERNAL: Returns the ServerSession that the Factory will be using and initializes it if it is not available. This method makes use of the partially constructed session stored in our setupImpl and completes its construction | |
| getBeginEarlyTransaction | back to summary |
|---|---|
| public boolean getBeginEarlyTransaction() Return default join existing transaction property, allows reading through write connection. | |
| getCache | back to summary |
|---|---|
| public Cache getCache() Implements jakarta. Access the cache that is associated with the entity manager factory (the "second level cache").
| |
| getCloseOnCommit | back to summary |
|---|---|
| public boolean getCloseOnCommit() Return default property to avoid resuming unit of work if going to be closed on commit anyway. | |
| getCommitOrder | back to summary |
|---|---|
| public UnitOfWork. Return if updates should be ordered by primary key, to avoid potential database deadlocks. | |
| getCommitWithoutPersistRules | back to summary |
|---|---|
| public boolean getCommitWithoutPersistRules() Return default property to avoid discover new objects in unit of work if application always uses persist. | |
| getCriteriaBuilder | back to summary |
|---|---|
| public CriteriaBuilder getCriteriaBuilder() Implements jakarta. Doc from jakarta. Return an instance of
| |
| getDatabaseSession | back to summary |
|---|---|
| public DatabaseSessionImpl getDatabaseSession() Implements org. INTERNAL: Returns the ServerSession that the Factory will be using and initializes it if it is not available. This method makes use of the partially constructed session stored in our setupImpl and completes its construction
| |
| getFlushClearCache | back to summary |
|---|---|
| public String getFlushClearCache() Return the default FlashClearCache mode to be used. Relevant only in case call to flush method followed by call to clear method. | |
| getFlushMode | back to summary |
|---|---|
| public FlushModeType getFlushMode() Return default property, allows flush before query to be avoided. | |
| getIdentifier | back to summary |
|---|---|
| public Object getIdentifier(Object entity) Implements jakarta. Returns the id of the entity. A generated id is not guaranteed to be available until after the database insert has occurred. Returns null if the entity does not yet have an id
| |
| getMetamodel | back to summary |
|---|---|
| public Metamodel getMetamodel() Implements jakarta. Return an instance of Metamodel interface for access to the metamodel of the persistence unit.
| |
| getOwner | back to summary |
|---|---|
| public JpaEntityManagerFactory getOwner() INTERNAL: Get the EntityManagerFactoryImpl that created this | |
| getPersistenceUnitUtil | back to summary |
|---|---|
| public PersistenceUnitUtil getPersistenceUnitUtil() Implements jakarta. Return interface providing access to utility methods for the persistence unit.
| |
| getPersistOnCommit | back to summary |
|---|---|
| public boolean getPersistOnCommit() Return default property to avoid discover new objects in unit of work if application always uses persist. | |
| getProperties | back to summary |
|---|---|
| public Map Implements jakarta. Doc from jakarta. 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.
| |
| getProperty | back to summary |
|---|---|
| public Object getProperty(String name) The method return user defined property passed in from EntityManagerFactory. | |
| getReferenceMode | back to summary |
|---|---|
| public ReferenceMode getReferenceMode() Return default property, allows weak unit of work references. | |
| getServerSession | back to summary |
|---|---|
| public ServerSession getServerSession() Implements org. INTERNAL: Returns the ServerSession that the Factory will be using and initializes it if it is not available. This method makes use of the partially constructed session stored in our setupImpl and completes its construction TODO: should throw IllegalStateException if not ServerSession
| |
| getSessionBroker | back to summary |
|---|---|
| public SessionBroker getSessionBroker() Implements org. INTERNAL: Returns the SessionBroker that the Factory will be using and initializes it if it is not available. This method makes use of the partially constructed session stored in our setupImpl and completes its construction TODO: should throw IllegalStateException if not SessionBroker
| |
| getSetupImpl | back to summary |
|---|---|
| public EntityManagerSetupImpl getSetupImpl() INTERNAL: Return the EntityManagerSetupImpl associated with this factory | |
| isLoaded | back to summary |
|---|---|
| public boolean isLoaded(Object entity, String attributeName) Implements jakarta. Determine the load state of a given persistent attribute of an entity belonging to the persistence unit. | |
| isLoaded | back to summary |
|---|---|
| public boolean isLoaded(Object entity) Implements jakarta. Determine the load state of an entity belonging to the persistence unit. This method can be used to determine the load state of an entity passed as a reference. An entity is considered loaded if all attributes for which FetchType EAGER has been specified have been loaded. The isLoaded(Object, String) method should be used to determine the load state of an attribute. Not doing so might lead to unintended loading of state. | |
| isOpen | back to summary |
|---|---|
| public boolean isOpen() Implements jakarta. Indicates whether or not this factory is open. Returns
| |
| processProperties | back to summary |
|---|---|
| protected void processProperties(Map<K, V> properties) Process all EntityManager properties. This allows all EntityManager properties specified in the persistence.xml, factory properties, or System properties to be preprocessed. This save the cost of processing these properties each time an EntityManager is created, which can add considerable overhead to both performance and concurrency as System properties are a Hashtable and synchronized. ATTENTION: If you add a new property to be processed in this method please also add the property's name to PersistenceUnitProperties.supportedNonServerSessionProperties | |
| refreshMetadata | back to summary |
|---|---|
| public void refreshMetadata(Map<K, V> properties) Implements org. ADVANCED: Re-bootstrap this factory. This method will rebuild the EntityManagerFactory. It should be used in conjunction with a MetadataSource to allow mappings to be changed in a running system. All existing EntityMangers will continue to function with the old metadata, but new factories will use the new metadata. This call will throw an exception when called on EntityManagerFactoryImplDelegate
| |
| setBeginEarlyTransaction | back to summary |
|---|---|
| public void setBeginEarlyTransaction(boolean beginEarlyTransaction) Set default join existing transaction property, allows reading through write connection. | |
| setCloseOnCommit | back to summary |
|---|---|
| public void setCloseOnCommit(boolean closeOnCommit) Set default property to avoid resuming unit of work if going to be closed on commit anyway. | |
| setCommitOrder | back to summary |
|---|---|
| public void setCommitOrder(UnitOfWork. Set update ordering by primary key, to avoid potential database deadlocks. | |
| setCommitWithoutPersistRules | back to summary |
|---|---|
| public void setCommitWithoutPersistRules(boolean commitWithoutPersistRules) Set default property to avoid discover new objects in unit of work if application always uses persist. | |
| setFlushClearCache | back to summary |
|---|---|
| public void setFlushClearCache(String flushClearCache) Set the default FlashClearCache mode to be used. Relevant only in case call to flush method followed by call to clear method. | |
| setFlushMode | back to summary |
|---|---|
| public void setFlushMode(FlushModeType flushMode) Set default property, allows flush before query to be avoided. | |
| setMetamodel | back to summary |
|---|---|
| public void setMetamodel(Metamodel aMetamodel) INTERNAL: Convenience function to allow us to reset the Metamodel in the possible case that we want to regenerate it. This function is outside of the JPA 2.0 specification.
| |
| setPersistOnCommit | back to summary |
|---|---|
| public void setPersistOnCommit(boolean persistOnCommit) Set default property to avoid discover new objects in unit of work if application always uses persist. | |
| setReferenceMode | back to summary |
|---|---|
| public void setReferenceMode(ReferenceMode referenceMode) Set default property, allows weak unit of work references. | |
| setShouldValidateExistence | back to summary |
|---|---|
| public void setShouldValidateExistence(boolean shouldValidateExistence) Set the default to determine if does-exist should be performed on persist. | |
| shouldValidateExistence | back to summary |
|---|---|
| public boolean shouldValidateExistence() Return the default to determine if does-exist should be performed on persist. | |
| unwrap | back to summary |
|---|---|
| public EntityManagerFactoryDelegate unwrap() Implements org. Gets the underlying implementation of the EntityManagerFactory. This method will return a version of EntityManagerFactory that is based on the available metadata at the time it is called. Future calls to refresh will not affect that metadata on this EntityManagerFactory.
| |
| unwrap | back to summary |
|---|---|
| public <T> T unwrap(Class<T> cls) Implements jakarta. Doc from jakarta. 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. | |
| verifyOpen | back to summary |
|---|---|
| protected void verifyOpen() | |