public class EntityManagerFactoryDelegate extends Object implements jakarta.persistence.EntityManagerFactory, jakarta.persistence.PersistenceUnitUtil, JpaEntityManagerFactory
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.
EntityManager,
JpaEntityManager,
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.CommitOrderType |
commitOrder
Order updates by id to avoid potential deadlocks.
|
protected boolean |
commitWithoutPersistRules |
protected String |
flushClearCache
Default FlashClearCache mode to be used.
|
protected jakarta.persistence.FlushModeType |
flushMode
Default property, allows flush before query to be avoided.
|
protected boolean |
isOpen
Stores if closed has been called.
|
protected jakarta.persistence.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 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 Set<String> |
supportedNonServerSessionProperties
INTERNAL: The following properties passed to createEMF cached and
processed on the emf directly.
|
| Constructor and Description |
|---|
EntityManagerFactoryDelegate(AbstractSession databaseSession,
JpaEntityManagerFactory owner)
Will return an instance of the Factory.
|
EntityManagerFactoryDelegate(EntityManagerSetupImpl setupImpl,
Map properties,
JpaEntityManagerFactory owner) |
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 |
|---|---|
<T> void |
addNamedEntityGraph(String graphName,
jakarta.persistence.EntityGraph<T> entityGraph) |
void |
addNamedQuery(String name,
jakarta.persistence.Query query) |
void |
close()
Closes this factory, releasing any resources that might be held by this
factory.
|
jakarta.persistence.EntityManager |
createEntityManager()
PUBLIC: Returns an EntityManager for this deployment.
|
jakarta.persistence.EntityManager |
createEntityManager(Map properties)
PUBLIC: Returns an EntityManager for this deployment.
|
jakarta.persistence.EntityManager |
createEntityManager(jakarta.persistence.SynchronizationType synchronizationType) |
jakarta.persistence.EntityManager |
createEntityManager(jakarta.persistence.SynchronizationType synchronizationType,
Map map) |
protected EntityManagerImpl |
createEntityManagerImpl(Map properties,
jakarta.persistence.SynchronizationType syncType) |
protected void |
finalize() |
AbstractSession |
getAbstractSession()
INTERNAL: Returns the ServerSession that the Factory will be using and
initializes it if it is not available.
|
boolean |
getBeginEarlyTransaction()
Return default join existing transaction property, allows reading through
write connection.
|
jakarta.persistence.Cache |
getCache()
Access the cache that is associated with the entity manager
factory (the "second level cache").
|
boolean |
getCloseOnCommit()
Return default property to avoid resuming unit of work if going to be
closed on commit anyway.
|
UnitOfWork.CommitOrderType |
getCommitOrder()
Return if updates should be ordered by primary key, to avoid potential database deadlocks.
|
boolean |
getCommitWithoutPersistRules()
Return default property to avoid discover new objects in unit of work if
application always uses persist.
|
jakarta.persistence.criteria.CriteriaBuilder |
getCriteriaBuilder() |
DatabaseSessionImpl |
getDatabaseSession()
INTERNAL: Returns the ServerSession that the Factory will be using and
initializes it if it is not available.
|
String |
getFlushClearCache()
Return the default FlashClearCache mode to be used.
|
jakarta.persistence.FlushModeType |
getFlushMode()
Return default property, allows flush before query to be avoided.
|
Object |
getIdentifier(Object entity)
Returns the id of the entity.
|
jakarta.persistence.metamodel.Metamodel |
getMetamodel()
Return an instance of Metamodel interface for access to the metamodel of
the persistence unit.
|
JpaEntityManagerFactory |
getOwner()
INTERNAL:
Get the EntityManagerFactoryImpl that created this
|
jakarta.persistence.PersistenceUnitUtil |
getPersistenceUnitUtil()
Return interface providing access to utility methods for the persistence
unit.
|
boolean |
getPersistOnCommit()
Return default property to avoid discover new objects in unit of work if
application always uses persist.
|
Map<String,Object> |
getProperties() |
Object |
getProperty(String name)
The method return user defined property passed in from
EntityManagerFactory.
|
ReferenceMode |
getReferenceMode()
Return default property, allows weak unit of work references.
|
ServerSession |
getServerSession()
INTERNAL: Returns the ServerSession that the Factory will be using and
initializes it if it is not available.
|
SessionBroker |
getSessionBroker()
INTERNAL: Returns the SessionBroker that the Factory will be using and
initializes it if it is not available.
|
EntityManagerSetupImpl |
getSetupImpl()
INTERNAL:
Return the EntityManagerSetupImpl associated with this factory
|
boolean |
isLoaded(Object entity)
Determine the load state of an entity belonging to the persistence unit.
|
boolean |
isLoaded(Object entity,
String attributeName)
Determine the load state of a given persistent attribute of an entity
belonging to the persistence unit.
|
boolean |
isOpen()
Indicates whether or not this factory is open.
|
protected void |
processProperties(Map properties)
Process all EntityManager properties.
|
void |
refreshMetadata(Map properties)
ADVANCED:
Re-bootstrap this factory.
|
void |
setBeginEarlyTransaction(boolean beginEarlyTransaction)
Set default join existing transaction property, allows reading through
write connection.
|
void |
setCloseOnCommit(boolean closeOnCommit)
Set default property to avoid resuming unit of work if going to be closed
on commit anyway.
|
void |
setCommitOrder(UnitOfWork.CommitOrderType commitOrder)
Set update ordering by primary key, to avoid potential database deadlocks.
|
void |
setCommitWithoutPersistRules(boolean commitWithoutPersistRules)
Set default property to avoid discover new objects in unit of work if
application always uses persist.
|
void |
setFlushClearCache(String flushClearCache)
Set the default FlashClearCache mode to be used.
|
void |
setFlushMode(jakarta.persistence.FlushModeType flushMode)
Set default property, allows flush before query to be avoided.
|
void |
setMetamodel(jakarta.persistence.metamodel.Metamodel aMetamodel)
INTERNAL: Convenience function to allow us to reset the Metamodel in the
possible case that we want to regenerate it.
|
void |
setPersistOnCommit(boolean persistOnCommit)
Set default property to avoid discover new objects in unit of work if
application always uses persist.
|
void |
setReferenceMode(ReferenceMode referenceMode)
Set default property, allows weak unit of work references.
|
void |
setShouldValidateExistence(boolean shouldValidateExistence)
Set the default to determine if does-exist should be performed on
persist.
|
boolean |
shouldValidateExistence()
Return the default to determine if does-exist should be performed on
persist.
|
EntityManagerFactoryDelegate |
unwrap()
Gets the underlying implementation of the EntityManagerFactory.
|
<T> T |
unwrap(Class<T> cls) |
protected void |
verifyOpen() |
protected jakarta.persistence.Cache myCache
protected volatile AbstractSession session
protected EntityManagerSetupImpl setupImpl
protected boolean isOpen
protected Map properties
protected static final Set<String> supportedNonServerSessionProperties
protected boolean beginEarlyTransaction
protected jakarta.persistence.FlushModeType flushMode
protected ReferenceMode referenceMode
protected boolean closeOnCommit
protected boolean persistOnCommit
protected String flushClearCache
FlushClearCacheprotected boolean shouldValidateExistence
protected UnitOfWork.CommitOrderType commitOrder
protected boolean commitWithoutPersistRules
protected JpaEntityManagerFactory owner
public EntityManagerFactoryDelegate(AbstractSession databaseSession, JpaEntityManagerFactory owner)
databaseSession - public EntityManagerFactoryDelegate(EntityManagerSetupImpl setupImpl, Map properties, JpaEntityManagerFactory owner)
public EntityManagerFactoryDelegate(String persistenceUnitName, Map<String,Object> properties, List<ClassDescriptor> descriptors, JpaEntityManagerFactory owner)
public DatabaseSessionImpl getDatabaseSession()
getDatabaseSession in interface JpaEntityManagerFactorypublic AbstractSession getAbstractSession()
public EntityManagerSetupImpl getSetupImpl()
public ServerSession getServerSession()
getServerSession in interface JpaEntityManagerFactorypublic SessionBroker getSessionBroker()
getSessionBroker in interface JpaEntityManagerFactorypublic void close()
IllegalStateException, except for isOpen, which
will return false.close in interface jakarta.persistence.EntityManagerFactorypublic boolean isOpen()
true
until a call to close() is made.isOpen in interface jakarta.persistence.EntityManagerFactorypublic jakarta.persistence.EntityManager createEntityManager()
createEntityManager in interface jakarta.persistence.EntityManagerFactorypublic jakarta.persistence.EntityManager createEntityManager(Map properties)
createEntityManager in interface jakarta.persistence.EntityManagerFactorypublic jakarta.persistence.EntityManager createEntityManager(jakarta.persistence.SynchronizationType synchronizationType,
Map map)
createEntityManager in interface jakarta.persistence.EntityManagerFactorypublic jakarta.persistence.EntityManager createEntityManager(jakarta.persistence.SynchronizationType synchronizationType)
createEntityManager in interface jakarta.persistence.EntityManagerFactoryprotected EntityManagerImpl createEntityManagerImpl(Map properties, jakarta.persistence.SynchronizationType syncType)
public EntityManagerFactoryDelegate unwrap()
unwrap in interface JpaEntityManagerFactoryprotected void verifyOpen()
protected void finalize()
throws Throwable
public Object getProperty(String name)
protected void processProperties(Map properties)
public void refreshMetadata(Map properties)
refreshMetadata in interface JpaEntityManagerFactoryproperties - public boolean getBeginEarlyTransaction()
public void setBeginEarlyTransaction(boolean beginEarlyTransaction)
public jakarta.persistence.FlushModeType getFlushMode()
public void setFlushMode(jakarta.persistence.FlushModeType flushMode)
public ReferenceMode getReferenceMode()
public void setReferenceMode(ReferenceMode referenceMode)
public boolean getCloseOnCommit()
public void setCloseOnCommit(boolean closeOnCommit)
public boolean getPersistOnCommit()
public jakarta.persistence.PersistenceUnitUtil getPersistenceUnitUtil()
getPersistenceUnitUtil in interface jakarta.persistence.EntityManagerFactoryIllegalStateException - if the entity manager factory has been closed.public void setPersistOnCommit(boolean persistOnCommit)
public boolean getCommitWithoutPersistRules()
public void setCommitWithoutPersistRules(boolean commitWithoutPersistRules)
public String getFlushClearCache()
FlushClearCachepublic void setFlushClearCache(String flushClearCache)
FlushClearCachepublic boolean shouldValidateExistence()
public void setShouldValidateExistence(boolean shouldValidateExistence)
public jakarta.persistence.Cache getCache()
getCache in interface jakarta.persistence.EntityManagerFactoryCache interfaceIllegalStateException - if the entity manager factory has been closedEntityManagerFactory.getCache()public Map<String,Object> getProperties()
getProperties in interface jakarta.persistence.EntityManagerFactoryEntityManagerFactory.getProperties()public jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
getCriteriaBuilder in interface jakarta.persistence.EntityManagerFactoryEntityManagerFactory.getCriteriaBuilder()public jakarta.persistence.metamodel.Metamodel getMetamodel()
getMetamodel in interface jakarta.persistence.EntityManagerFactoryIllegalStateException - if the entity manager factory has been closed.EntityManagerFactory.getMetamodel()public JpaEntityManagerFactory getOwner()
public void setMetamodel(jakarta.persistence.metamodel.Metamodel aMetamodel)
aMetamodel - public boolean isLoaded(Object entity, String attributeName)
isLoaded in interface jakarta.persistence.PersistenceUnitUtilisLoaded in interface jakarta.persistence.PersistenceUtilentity - containing the attributeattributeName - name of attribute whose load state is to be determinedpublic boolean isLoaded(Object entity)
isLoaded in interface jakarta.persistence.PersistenceUnitUtilisLoaded in interface jakarta.persistence.PersistenceUtilentity - whose load state is to be determinedpublic Object getIdentifier(Object entity)
getIdentifier in interface jakarta.persistence.PersistenceUnitUtilentity - IllegalArgumentException - if the entity is found not to be an entity.public UnitOfWork.CommitOrderType getCommitOrder()
public void setCommitOrder(UnitOfWork.CommitOrderType commitOrder)
public void addNamedQuery(String name, jakarta.persistence.Query query)
addNamedQuery in interface jakarta.persistence.EntityManagerFactorypublic <T> T unwrap(Class<T> cls)
unwrap in interface jakarta.persistence.EntityManagerFactorypublic <T> void addNamedEntityGraph(String graphName, jakarta.persistence.EntityGraph<T> entityGraph)
addNamedEntityGraph in interface jakarta.persistence.EntityManagerFactoryCopyright © 2007–2021 Eclipse.org - EclipseLink Project. All rights reserved.