public class EntityManagerFactoryDelegate extends java.lang.Object implements 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.
javax.persistence.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 CommitOrderType |
commitOrder
Order updates by id to avoid potential deadlocks.
|
protected boolean |
commitWithoutPersistRules |
protected java.lang.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 java.util.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 java.util.Set<java.lang.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,
java.util.Map properties,
JpaEntityManagerFactory owner) |
EntityManagerFactoryDelegate(java.lang.String persistenceUnitName,
java.util.Map<java.lang.String,java.lang.Object> properties,
java.util.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(java.lang.String graphName,
<any> entityGraph) |
void |
addNamedQuery(java.lang.String name,
Query query) |
void |
close()
Closes this factory, releasing any resources that might be held by this
factory.
|
EntityManager |
createEntityManager()
PUBLIC: Returns an EntityManager for this deployment.
|
EntityManager |
createEntityManager(java.util.Map properties)
PUBLIC: Returns an EntityManager for this deployment.
|
EntityManager |
createEntityManager(SynchronizationType synchronizationType) |
EntityManager |
createEntityManager(SynchronizationType synchronizationType,
java.util.Map map) |
protected EntityManagerImpl |
createEntityManagerImpl(java.util.Map properties,
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.
|
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.
|
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.
|
CriteriaBuilder |
getCriteriaBuilder() |
DatabaseSessionImpl |
getDatabaseSession()
INTERNAL: Returns the ServerSession that the Factory will be using and
initializes it if it is not available.
|
java.lang.String |
getFlushClearCache()
Return the default FlashClearCache mode to be used.
|
FlushModeType |
getFlushMode()
Return default property, allows flush before query to be avoided.
|
java.lang.Object |
getIdentifier(java.lang.Object entity)
Returns the id of the entity.
|
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
|
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.
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties() |
java.lang.Object |
getProperty(java.lang.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(java.lang.Object entity)
Determine the load state of an entity belonging to the persistence unit.
|
boolean |
isLoaded(java.lang.Object entity,
java.lang.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(java.util.Map properties)
Process all EntityManager properties.
|
void |
refreshMetadata(java.util.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(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(java.lang.String flushClearCache)
Set the default FlashClearCache mode to be used.
|
void |
setFlushMode(FlushModeType flushMode)
Set default property, allows flush before query to be avoided.
|
void |
setMetamodel(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(java.lang.Class<T> cls) |
protected void |
verifyOpen() |
protected Cache myCache
protected volatile AbstractSession session
protected EntityManagerSetupImpl setupImpl
protected boolean isOpen
protected java.util.Map properties
protected static final java.util.Set<java.lang.String> supportedNonServerSessionProperties
protected boolean beginEarlyTransaction
protected FlushModeType flushMode
protected ReferenceMode referenceMode
protected boolean closeOnCommit
protected boolean persistOnCommit
protected java.lang.String flushClearCache
org.eclipse.persistence.config.FlushClearCacheprotected boolean shouldValidateExistence
protected CommitOrderType commitOrder
protected boolean commitWithoutPersistRules
protected JpaEntityManagerFactory owner
public EntityManagerFactoryDelegate(AbstractSession databaseSession,
JpaEntityManagerFactory owner)
databaseSession - public EntityManagerFactoryDelegate(EntityManagerSetupImpl setupImpl, java.util.Map properties, JpaEntityManagerFactory owner)
public EntityManagerFactoryDelegate(java.lang.String persistenceUnitName,
java.util.Map<java.lang.String,java.lang.Object> properties,
java.util.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.public boolean isOpen()
true
until a call to close() is made.public EntityManager createEntityManager()
public EntityManager createEntityManager(java.util.Map properties)
public EntityManager createEntityManager(SynchronizationType synchronizationType,
java.util.Map map)
public EntityManager createEntityManager(SynchronizationType synchronizationType)
protected EntityManagerImpl createEntityManagerImpl(java.util.Map properties, SynchronizationType syncType)
public EntityManagerFactoryDelegate unwrap()
unwrap in interface JpaEntityManagerFactoryprotected void verifyOpen()
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic java.lang.Object getProperty(java.lang.String name)
protected void processProperties(java.util.Map properties)
public void refreshMetadata(java.util.Map properties)
refreshMetadata in interface JpaEntityManagerFactoryproperties - public boolean getBeginEarlyTransaction()
public void setBeginEarlyTransaction(boolean beginEarlyTransaction)
public FlushModeType getFlushMode()
public void setFlushMode(FlushModeType flushMode)
public ReferenceMode getReferenceMode()
public void setReferenceMode(ReferenceMode referenceMode)
public boolean getCloseOnCommit()
public void setCloseOnCommit(boolean closeOnCommit)
public boolean getPersistOnCommit()
public PersistenceUnitUtil getPersistenceUnitUtil()
java.lang.IllegalStateException - if the entity manager factory has been closed.public void setPersistOnCommit(boolean persistOnCommit)
public boolean getCommitWithoutPersistRules()
public void setCommitWithoutPersistRules(boolean commitWithoutPersistRules)
public java.lang.String getFlushClearCache()
org.eclipse.persistence.config.FlushClearCachepublic void setFlushClearCache(java.lang.String flushClearCache)
org.eclipse.persistence.config.FlushClearCachepublic boolean shouldValidateExistence()
public void setShouldValidateExistence(boolean shouldValidateExistence)
public Cache getCache()
Cache interfacejava.lang.IllegalStateException - if the entity manager factory has been closedjavax.persistence.EntityManagerFactory#getCache()public java.util.Map<java.lang.String,java.lang.Object> getProperties()
javax.persistence.EntityManagerFactory#getProperties()public CriteriaBuilder getCriteriaBuilder()
javax.persistence.EntityManagerFactory#getCriteriaBuilder()public Metamodel getMetamodel()
java.lang.IllegalStateException - if the entity manager factory has been closed.javax.persistence.EntityManagerFactory#getMetamodel()public JpaEntityManagerFactory getOwner()
public void setMetamodel(Metamodel aMetamodel)
aMetamodel - public boolean isLoaded(java.lang.Object entity,
java.lang.String attributeName)
entity - containing the attributeattributeName - name of attribute whose load state is to be determinedpublic boolean isLoaded(java.lang.Object entity)
entity - whose load state is to be determinedpublic java.lang.Object getIdentifier(java.lang.Object entity)
entity - java.lang.IllegalArgumentException - if the entity is found not to be an entity.public CommitOrderType getCommitOrder()
public void setCommitOrder(CommitOrderType commitOrder)
public void addNamedQuery(java.lang.String name,
Query query)
public <T> T unwrap(java.lang.Class<T> cls)
public <T> void addNamedEntityGraph(java.lang.String graphName,
<any> entityGraph)