public class EntityManagerImpl extends java.lang.Object implements JpaEntityManager
Purpose: Contains the implementation of the EntityManager.
Description: This class provides the implementation for the combined EclipseLink and JPA EntityManager class.
Responsibilities: It is responsible for tracking transaction state and the objects within that transaction.
javax.persistence.EntityManager,
JpaEntityManager| Modifier and Type | Class and Description |
|---|---|
protected static class |
EntityManagerImpl.OperationType |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
beginEarlyTransaction
Join existing transaction property, allows reading through write
connection.
|
protected boolean |
cacheStoreBypass
Property to avoid writing to the cache on commit (merge)
|
protected boolean |
closeOnCommit
Property to avoid resuming unit of work if going to be closed on commit
anyway.
|
protected org.eclipse.persistence.sessions.UnitOfWork.CommitOrderType |
commitOrder
Allow updates to be ordered by id to avoid possible deadlocks.
|
protected boolean |
commitWithoutPersistRules |
protected java.util.Map<java.lang.String,ConnectionPolicy> |
connectionPolicies
In case of composite persistence unit this map is used instead of connectionPolicy attribute.
|
protected ConnectionPolicy |
connectionPolicy
Connection policy used to create ClientSession, allows using a different
pool/connection/exclusive connections.
|
protected AbstractSession |
databaseSession
References the DatabaseSession that this deployment is using.
|
protected RepeatableWriteUnitOfWork |
extendedPersistenceContext
Stores the UnitOfWork representing the persistence context.
|
protected EntityManagerFactoryDelegate |
factory
References to the parent factory that has created this entity manager.
|
protected java.lang.String |
flushClearCache
The FlashClearCache mode to be used.
|
protected FlushModeType |
flushMode
Flush mode property, allows flush before query to be avoided.
|
protected boolean |
isOpen
Store if this entity manager has been closed.
|
protected java.util.WeakHashMap<QueryImpl,QueryImpl> |
openQueriesMap
Keep a list of openQueries that are executed in this entity manager.
|
protected boolean |
persistOnCommit
Property to avoid discover new objects in unit of work if application
always uses persist.
|
protected java.util.Map |
properties
Local properties passed from createEntityManager.
|
protected AbstractSession |
readOnlySession
Stores a session used for read-only queries.
|
protected ReferenceMode |
referenceMode
Reference mode property, allows weak unit of work references to allow
garbage collection during a transaction.
|
protected boolean |
shouldValidateExistence
Determine if does-exist should be performed on persist.
|
protected SynchronizationType |
syncType
Tracks if this EntityManager should automatically associate with the transaction or not
|
protected TransactionWrapperImpl |
transaction
Allows transparent transactions across JTA and local transactions.
|
| Constructor and Description |
|---|
EntityManagerImpl(AbstractSession databaseSession,
java.util.Map properties,
SynchronizationType syncType)
Constructor called from the EntityManagerFactory to create an
EntityManager
|
EntityManagerImpl(AbstractSession databaseSession,
SynchronizationType syncType)
Constructor called from the EntityManagerFactory to create an
EntityManager
|
EntityManagerImpl(EntityManagerFactoryDelegate factory,
java.util.Map properties,
SynchronizationType syncType)
Constructor called from the EntityManagerFactory to create an
EntityManager
|
EntityManagerImpl(java.lang.String sessionName)
Constructor returns an EntityManager assigned to the a particular
DatabaseSession.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addOpenQuery(QueryImpl query)
Queries that leave the connection and are executed against this entity
manager will be added here.
|
protected java.lang.Object |
checkForTransaction(boolean validateExistence)
Return the current, joined transaction object.
|
void |
clear()
Clear the persistence context, causing all managed entities to become
detached.
|
void |
close()
Closes this EntityManager.
|
protected void |
closeOpenQueries()
Close any open queries executed against this entity manager.0
|
boolean |
contains(java.lang.Object entity)
Check if the instance belongs to the current persistence context.
|
protected boolean |
contains(java.lang.Object entity,
UnitOfWork uow)
Check if the instance belongs to the current persistence context.
|
java.lang.Object |
copy(java.lang.Object entityOrEntities,
AttributeGroup group)
This method will return copy the passed entity using the passed AttributeGroup.
|
protected void |
createConnectionPolicies(java.util.Map mapOfProperties)
Create connection policy using properties.
|
protected void |
createConnectionPolicy()
Create connection policy using properties.
|
protected static ConnectionPolicy |
createConnectionPolicy(ServerSession serverSession,
java.util.Map properties)
Create connection policy using properties.
|
javax.persistence.Query |
createDescriptorNamedQuery(java.lang.String queryName,
java.lang.Class descriptorClass)
This method will create a query object that wraps a EclipseLink Named Query.
|
javax.persistence.Query |
createDescriptorNamedQuery(java.lang.String queryName,
java.lang.Class descriptorClass,
java.util.List argumentTypes)
This method will create a query object that wraps a EclipseLink Named Query.
|
<T> <any> |
createEntityGraph(java.lang.Class<T> rootType) |
EntityGraph |
createEntityGraph(java.lang.String graphName) |
Query |
createNamedQuery(java.lang.String name)
Create an instance of Query for executing a named query (in EJBQL or
native SQL).
|
<T> <any> |
createNamedQuery(java.lang.String name,
java.lang.Class<T> resultClass)
Create an instance of TypedQuery for executing a
named query (in the Java Persistence query language
or in native SQL).
|
StoredProcedureQuery |
createNamedStoredProcedureQuery(java.lang.String name)
Create an instance of StoredProcedureQuery for executing a
stored procedure in the database.
|
Query |
createNativeQuery(java.lang.String sqlString)
Create an instance of Query for executing a native SQL query.
|
Query |
createNativeQuery(java.lang.String sqlString,
java.lang.Class resultType)
This method is used to create a query using SQL.
|
Query |
createNativeQuery(java.lang.String sqlString,
java.lang.String resultSetMapping)
Create an instance of Query for executing a native SQL query.
|
<T> <any> |
createQuery(<any> criteriaQuery) |
javax.persistence.Query |
createQuery(Call call)
This method is used to create a query using a EclipseLink Call.
|
javax.persistence.Query |
createQuery(Call call,
java.lang.Class entityClass)
This method is used to create a query using a EclipseLink Call.
|
Query |
createQuery(CriteriaDelete deleteQuery)
This method is used to create a query using a EclipseLink DatabaseQuery.
|
Query |
createQuery(CriteriaUpdate updateQuery)
This method is used to create a query using a EclipseLink DatabaseQuery.
|
javax.persistence.Query |
createQuery(DatabaseQuery databaseQuery)
This method is used to create a query using a EclipseLink DatabaseQuery.
|
javax.persistence.Query |
createQuery(Expression expression,
java.lang.Class resultType)
This method is used to create a query using a EclipseLink Expression and
the return type.
|
Query |
createQuery(java.lang.String jpqlString)
Create an instance of Query for executing an JPQL query.
|
<T> <any> |
createQuery(java.lang.String qlString,
java.lang.Class<T> resultClass)
Create an instance of TypedQuery for executing a
Java Persistence query language statement.
|
javax.persistence.Query |
createQueryByExample(java.lang.Object exampleObject)
This method is used to create a query using a EclipseLink by example.
|
protected DatabaseQuery |
createQueryInternal(Expression expression,
java.lang.Class resultType)
This method is used to create a query using a EclipseLink Expression and
the return type.
|
StoredProcedureQuery |
createStoredProcedureQuery(java.lang.String procedureName)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
StoredProcedureQuery |
createStoredProcedureQuery(java.lang.String procedureName,
java.lang.Class... resultClasses)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
StoredProcedureQuery |
createStoredProcedureQuery(java.lang.String procedureName,
java.lang.String... resultSetMappings)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
void |
detach(java.lang.Object entity)
Remove the given entity from the persistence context, causing a managed
entity to become detached.
|
protected void |
detectTransactionWrapper() |
<T> T |
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
Find by primary key.
|
<T> T |
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode)
Find by primary key and lock.
|
<T> T |
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Find by primary key and lock.
|
<T> T |
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
java.util.Map<java.lang.String,java.lang.Object> properties)
Find by primary key, using the specified properties.
|
java.lang.Object |
find(java.lang.String entityName,
java.lang.Object primaryKey)
Find by primary key.
|
protected java.lang.Object |
findInternal(ClassDescriptor descriptor,
AbstractSession session,
java.lang.Object id,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Find by primary key.
|
void |
flush()
Synchronize the persistence context with the underlying database.
|
AbstractSession |
getAbstractSession()
Return the underlying database session
|
RepeatableWriteUnitOfWork |
getActivePersistenceContext(java.lang.Object txn) |
Session |
getActiveSession()
This method returns the current session to the requestor.
|
AbstractSession |
getActiveSessionIfExists()
This method returns the current session to the requestor.
|
CriteriaBuilder |
getCriteriaBuilder()
Return an instance of CriteriaBuilder for the creation of
Criteria API Query objects.
|
DatabaseSessionImpl |
getDatabaseSession()
Return the underlying database session
|
java.lang.Object |
getDelegate()
Return the underlying provider object for the EntityManager, if
available.
|
EntityGraph |
getEntityGraph(java.lang.String graphName) |
<T> java.util.List<<any>> |
getEntityGraphs(java.lang.Class<T> entityClass) |
EntityManagerFactory |
getEntityManagerFactory()
Return the entity manager factory for the entity manager.
|
FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained in the
persistence context.
|
LockModeType |
getLockMode(java.lang.Object entity) |
DatabaseSessionImpl |
getMemberDatabaseSession(java.lang.Class cls)
Return the member DatabaseSessionImpl that maps cls in session broker.
|
ServerSession |
getMemberServerSession(java.lang.Class cls)
Return the member ServerSession that maps cls in session broker.
|
java.lang.String |
getMemberSessionName(java.lang.Class cls)
Return the name of member session that maps cls.
|
Metamodel |
getMetamodel()
Return an instance of Metamodel interface for access to the
metamodel of the persistence unit.
|
protected java.util.Map<QueryImpl,QueryImpl> |
getOpenQueriesMap()
Return the weak reference to the open queries.
|
protected java.util.Set<QueryImpl> |
getOpenQueriesSet()
Return the weak reference to the open queries.
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Get the properties and associated values that are in effect for the
entity manager.
|
protected java.lang.String |
getPropertiesHandlerProperty(java.lang.String name)
Get the local EntityManager property from the properties Map.
|
protected static java.lang.String |
getPropertiesHandlerProperty(java.lang.String name,
java.lang.String value)
Verifies and (if required) translates the value.
|
java.lang.Object |
getProperty(java.lang.String name)
The method search for user defined property passed in from EntityManager,
if it is not found then search for it from EntityManagerFactory
properties.
|
protected java.util.HashMap<java.lang.String,java.lang.Object> |
getQueryHints(java.lang.Object entity,
EntityManagerImpl.OperationType operation)
Before any find or refresh operation, gather any persistence unit
properties that should be applied to the query.
|
protected ReadObjectQuery |
getReadObjectQuery(java.lang.Class referenceClass,
java.lang.Object primaryKey,
java.util.Map properties)
Build a selection query for the primary key values.
|
protected ReadObjectQuery |
getReadObjectQuery(java.util.Map properties)
Build a selection query using the given properties.
|
protected ReadObjectQuery |
getReadObjectQuery(java.lang.Object entity,
java.util.Map properties)
Build a selection query for the given entity.
|
Session |
getReadOnlySession()
Return a read-only session (client session) for read-only operations.
|
<T> T |
getReference(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
Get an instance, whose state may be lazily fetched.
|
ServerSession |
getServerSession()
Return the underlying server session, throws ClassCastException if it's not a ServerSession.
|
Session |
getSession()
This method will return a Session outside of a transaction and null
within a transaction.
|
SessionBroker |
getSessionBroker()
Return the underlying session broker, throws ClassCastException if it's not a SessionBroker.
|
java.util.Set<java.lang.String> |
getSupportedProperties()
Get the names of the properties that are supported for use with the
entity manager.
|
SynchronizationType |
getSyncType()
INTERNAL:
Tracks if this EntityManager should automatically associate with the transaction or not
|
javax.persistence.EntityTransaction |
getTransaction()
Returns the resource-level transaction object.
|
UnitOfWork |
getUnitOfWork()
This method will return the active UnitOfWork
|
boolean |
hasActivePersistenceContext()
This method is used in contains to check if we already have a persistence
context.
|
protected void |
initialize(java.util.Map properties)
Initialize the state after construction.
|
boolean |
isBroker()
Indicates whether the underlying session is a session broker.
|
boolean |
isFlushModeAUTO()
Internal method.
|
boolean |
isJoinedToTransaction() |
boolean |
isOpen()
Indicates whether or not this entity manager and its entity manager factory
are open.
|
protected static boolean |
isPropertyToBeAdded(javax.sql.DataSource ds,
java.lang.String dsName) |
protected static boolean |
isPropertyToBeAdded(java.lang.String value)
Property value is to be added if it's non null and not an empty string.
|
protected static boolean |
isPropertyToBeRemoved(java.lang.String value)
Property value of an empty string indicates that the existing property
should be removed.
|
protected static java.lang.Boolean |
isPropertyValueToBeUpdated(java.lang.String oldValue,
java.lang.String newValue) |
void |
joinTransaction()
Indicate to the EntityManager that a JTA transaction is active.
|
void |
load(java.lang.Object entityOrEntities,
AttributeGroup group)
This method will load the passed entity or collection of entities using the passed AttributeGroup.
|
void |
lock(java.lang.Object entity,
LockModeType lockMode)
Set the lock mode for an entity object contained in the persistence
context.
|
void |
lock(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Set the lock mode for an entity object contained in the persistence
context.
|
<T> T |
merge(T entity)
Merge the state of the given entity into the current persistence context,
using the unqualified class name as the entity name.
|
protected java.lang.Object |
mergeInternal(java.lang.Object entity)
Merge the state of the given entity into the current persistence context,
using the unqualified class name as the entity name.
|
void |
persist(java.lang.Object entity)
If in a transaction this method will check for existence and register the
object if it is new.
|
protected void |
processProperties()
Process the local EntityManager properties only.
|
static void |
processUnfetchedAttribute(FetchGroupTracker entity,
java.lang.String attributeName)
INTERNAL:
Load/fetch the unfetched object.
|
static void |
processUnfetchedAttributeForSet(FetchGroupTracker entity,
java.lang.String attributeName)
INTERNAL:
Load/fetch the unfetched object.
|
void |
refresh(java.lang.Object entity)
Refresh the state of the instance from the database.
|
void |
refresh(java.lang.Object entity,
LockModeType lockMode)
Refresh the state of the instance from the database, overwriting changes
made to the entity, if any, and lock it with respect to given lock mode
type.
|
void |
refresh(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Refresh the state of the instance from the database, overwriting changes
made to the entity, if any, and lock it with respect to given lock mode
type.
|
void |
refresh(java.lang.Object entity,
java.util.Map<java.lang.String,java.lang.Object> properties)
Refresh the state of the instance from the database, using the specified
properties, and overwriting changes made to the entity, if any.
|
void |
remove(java.lang.Object entity)
Remove the instance.
|
void |
removeExtendedPersistenceContext()
Internal method called by EntityTransactionImpl class in case of
transaction rollback.
|
void |
setAbstractSession(AbstractSession session)
INTERNAL:
Set the underlying database session
|
protected void |
setEntityTransactionWrapper() |
void |
setFlushMode(FlushModeType flushMode)
Set the flush mode that applies to all objects contained in the
persistence context.
|
protected void |
setJTATransactionWrapper() |
void |
setProperties(java.util.Map properties)
Use this method to set properties into existing EntityManager that are
normally passed to createEntityManager method.
|
void |
setProperty(java.lang.String propertyName,
java.lang.Object value) |
protected void |
setRollbackOnly()
Internal method.
|
boolean |
shouldBeginEarlyTransaction()
Indicate the early transaction should be forced to start.
|
boolean |
shouldFlushBeforeQuery() |
<T> T |
unwrap(java.lang.Class<T> cls)
Return an object of the specified type to allow access to the
provider-specific API.
|
void |
verifyOpen() |
void |
verifyOpenWithSetRollbackOnly()
used to save having to constantly use a try/catch to call setRollbackOnly
|
protected TransactionWrapperImpl transaction
protected boolean isOpen
protected RepeatableWriteUnitOfWork extendedPersistenceContext
protected AbstractSession readOnlySession
protected AbstractSession databaseSession
protected EntityManagerFactoryDelegate factory
protected boolean beginEarlyTransaction
protected java.util.Map properties
protected FlushModeType flushMode
protected ReferenceMode referenceMode
protected ConnectionPolicy connectionPolicy
protected java.util.Map<java.lang.String,ConnectionPolicy> connectionPolicies
protected java.util.WeakHashMap<QueryImpl,QueryImpl> openQueriesMap
protected boolean closeOnCommit
protected boolean persistOnCommit
protected boolean cacheStoreBypass
protected java.lang.String flushClearCache
org.eclipse.persistence.config.FlushClearCacheprotected boolean shouldValidateExistence
protected org.eclipse.persistence.sessions.UnitOfWork.CommitOrderType commitOrder
protected boolean commitWithoutPersistRules
protected SynchronizationType syncType
public EntityManagerImpl(java.lang.String sessionName)
sessionName - the DatabaseSession name that should be used. This constructor
can potentially throw EclipseLink exceptions regarding the
existence, or errors with the specified session.public EntityManagerImpl(AbstractSession databaseSession,
SynchronizationType syncType)
databaseSession - the databaseSession assigned to this deployment.public EntityManagerImpl(AbstractSession databaseSession,
java.util.Map properties,
SynchronizationType syncType)
databaseSession - the databaseSession assigned to this deployment. Note: The
properties argument is provided to allow properties to be
passed into this EntityManager, but there are currently no
such properties implementedpublic EntityManagerImpl(EntityManagerFactoryDelegate factory, java.util.Map properties, SynchronizationType syncType)
factory - the EntityMangerFactoryImpl that created this entity manager.
Note: The properties argument is provided to allow properties
to be passed into this EntityManager, but there are currently
no such properties implementedprotected java.util.Map<QueryImpl,QueryImpl> getOpenQueriesMap()
protected java.util.Set<QueryImpl> getOpenQueriesSet()
public void addOpenQuery(QueryImpl query)
query - protected void initialize(java.util.Map properties)
public void clear()
public void removeExtendedPersistenceContext()
public void persist(java.lang.Object entity)
entity - java.lang.IllegalArgumentException - if the given Object is not an entity.public <T> T merge(T entity)
entity - protected java.lang.Object mergeInternal(java.lang.Object entity)
entity - java.lang.IllegalArgumentException - if given Object is not an entity or is a removed entitypublic void remove(java.lang.Object entity)
entity - java.lang.IllegalArgumentException - if Object passed in is not an entitypublic <T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
entityClass - - the entity class to find.primaryKey - - the entity primary key value, or primary key class, or a
List of primary key values.java.lang.IllegalArgumentException - if the first argument does not denote an entity type or the
second argument is not a valid type for that entity's primary
key.public <T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
java.util.Map<java.lang.String,java.lang.Object> properties)
entityClass - primaryKey - properties - standard and vendor-specific propertiesjava.lang.IllegalArgumentException - if the first argument does not denote an entity type or the
second argument is is not a valid type for that entity's
primary key or is nullpublic <T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode)
entityClass - primaryKey - lockMode - java.lang.IllegalArgumentException - if the first argument does not denote an entity type or the
second argument is not a valid type for that entity's primary
key or is nullTransactionRequiredException - if there is no transaction and a lock mode other than NONE is
setOptimisticLockException - if the optimistic version check failsPessimisticLockException - if pessimistic locking fails and the transaction is rolled
backLockTimeoutException - if pessimistic locking fails and only the statement is rolled
backPersistenceException - if an unsupported lock call is madepublic <T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
entityClass - primaryKey - lockMode - properties - standard and vendor-specific properties and hintsjava.lang.IllegalArgumentException - if the first argument does not denote an entity type or the
second argument is not a valid type for that entity's primary
key or is nullTransactionRequiredException - if there is no transaction and a lock mode other than NONE is
setOptimisticLockException - if the optimistic version check failsPessimisticLockException - if pessimistic locking fails and the transaction is rolled
backLockTimeoutException - if pessimistic locking fails and only the statement is rolled
backPersistenceException - if an unsupported lock call is madepublic java.lang.Object find(java.lang.String entityName,
java.lang.Object primaryKey)
entityName - - the entity class to find.primaryKey - - the entity primary key value, or primary key class, or a
List of primary key values.java.lang.IllegalArgumentException - if the first argument does not indicate an entity or if the
second argument is not a valid type for that entity's
primaryKey.protected java.lang.Object findInternal(ClassDescriptor descriptor,
AbstractSession session,
java.lang.Object id,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
entityClass - - the entity class to find.primaryKey - - the entity primary key value, or primary key class, or a
List of primary key values.java.lang.IllegalArgumentException - if the first argument does not denote an entity type or the
second argument is not a valid type for that entity's primary
key.public void flush()
protected void detectTransactionWrapper()
public void refresh(java.lang.Object entity)
entity - instance registered in the current persistence context.public void refresh(java.lang.Object entity,
java.util.Map<java.lang.String,java.lang.Object> properties)
entity - properties - standard and vendor-specific propertiesjava.lang.IllegalArgumentException - if the instance is not an entity or the entity is not managedTransactionRequiredException - if invoked on a container-managed entity manager of type
PersistenceContextType.TRANSACTION and there is no
transaction.EntityNotFoundException - if the entity no longer exists in the databasepublic void refresh(java.lang.Object entity,
LockModeType lockMode)
entity - lockMode - java.lang.IllegalArgumentException - if the instance is not an entity or the entity is not managedTransactionRequiredException - if there is no transactionEntityNotFoundException - if the entity no longer exists in the databasePessimisticLockException - if pessimistic locking fails and the transaction is rolled
backLockTimeoutException - if pessimistic locking fails and only the statement is rolled
backPersistenceException - if an unsupported lock call is madepublic void refresh(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
entity - lockMode - properties - standard and vendor-specific properties and hintsjava.lang.IllegalArgumentException - if the instance is not an entity or the entity is not managedTransactionRequiredException - if there is no transactionEntityNotFoundException - if the entity no longer exists in the databasePessimisticLockException - if pessimistic locking fails and the transaction is rolled
backLockTimeoutException - if pessimistic locking fails and only the statement is rolled
backPersistenceException - if an unsupported lock call is madepublic boolean contains(java.lang.Object entity)
entity - java.lang.IllegalArgumentException - if given Object is not an entityprotected boolean contains(java.lang.Object entity,
UnitOfWork uow)
public javax.persistence.Query createDescriptorNamedQuery(java.lang.String queryName,
java.lang.Class descriptorClass)
JpaEntityManagercreateDescriptorNamedQuery in interface JpaEntityManagerpublic javax.persistence.Query createDescriptorNamedQuery(java.lang.String queryName,
java.lang.Class descriptorClass,
java.util.List argumentTypes)
JpaEntityManagercreateDescriptorNamedQuery in interface JpaEntityManagerpublic Query createNamedQuery(java.lang.String name)
name - the name of a query defined in metadatapublic <T> <any> createNamedQuery(java.lang.String name,
java.lang.Class<T> resultClass)
name - the name of a query defined in metadataresultClass - the type of the query resultjava.lang.IllegalArgumentException - if a query has not been
defined with the given name or if the query string is
found to be invalidpublic StoredProcedureQuery createNamedStoredProcedureQuery(java.lang.String name)
name - name assigned to the stored procedure query
in metadatajava.lang.IllegalArgumentException - if a query has not been
defined with the given namepublic Query createNativeQuery(java.lang.String sqlString)
sqlString - a native SQL query stringpublic Query createNativeQuery(java.lang.String sqlString,
java.lang.Class resultType)
public Query createNativeQuery(java.lang.String sqlString,
java.lang.String resultSetMapping)
sqlString - a native SQL query stringresultSetMapping - the name of the result set mappingjava.lang.IllegalArgumentException - if query string is not validpublic Session getActiveSession()
getActiveSession in interface JpaEntityManagerpublic AbstractSession getActiveSessionIfExists()
public java.lang.Object getDelegate()
public FlushModeType getFlushMode()
public UnitOfWork getUnitOfWork()
getUnitOfWork in interface JpaEntityManagerpublic Session getSession()
getSession in interface JpaEntityManagerpublic javax.persistence.EntityTransaction getTransaction()
java.lang.IllegalStateException - if invoked on a JTA EntityManager.public java.lang.Object getProperty(java.lang.String name)
name - protected ReadObjectQuery getReadObjectQuery(java.lang.Class referenceClass,
java.lang.Object primaryKey,
java.util.Map properties)
protected ReadObjectQuery getReadObjectQuery(java.util.Map properties)
protected ReadObjectQuery getReadObjectQuery(java.lang.Object entity,
java.util.Map properties)
public <T> T getReference(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
entityClass - primaryKey - java.lang.IllegalArgumentException - if the first argument does not denote an entity type or the
second argument is not a valid type for that entity's primary
key.EntityNotFoundException - if the entity state cannot be accessed.public Session getReadOnlySession()
public DatabaseSessionImpl getDatabaseSession()
getDatabaseSession in interface JpaEntityManagerpublic AbstractSession getAbstractSession()
getAbstractSession in interface JpaEntityManagerpublic void setAbstractSession(AbstractSession session)
public ServerSession getServerSession()
getServerSession in interface JpaEntityManagerpublic SessionBroker getSessionBroker()
getSessionBroker in interface JpaEntityManagerpublic DatabaseSessionImpl getMemberDatabaseSession(java.lang.Class cls)
getMemberDatabaseSession in interface JpaEntityManagerpublic ServerSession getMemberServerSession(java.lang.Class cls)
getMemberServerSession in interface JpaEntityManagerpublic java.lang.String getMemberSessionName(java.lang.Class cls)
getMemberSessionName in interface JpaEntityManagerpublic javax.persistence.Query createQuery(Expression expression,
java.lang.Class resultType)
createQuery in interface JpaEntityManagerpublic javax.persistence.Query createQuery(DatabaseQuery databaseQuery)
createQuery in interface JpaEntityManagerpublic <T> <any> createQuery(<any> criteriaQuery)
EntityManager#createQuery(javax.persistence.criteria.CriteriaQuery)public javax.persistence.Query createQueryByExample(java.lang.Object exampleObject)
createQueryByExample in interface JpaEntityManagerpublic javax.persistence.Query createQuery(Call call)
createQuery in interface JpaEntityManagerpublic javax.persistence.Query createQuery(Call call,
java.lang.Class entityClass)
createQuery in interface JpaEntityManagerpublic Query createQuery(java.lang.String jpqlString)
createQuery in interface JpaEntityManagerjpqlString - an JPQL query stringpublic <T> <any> createQuery(java.lang.String qlString,
java.lang.Class<T> resultClass)
qlString - a Java Persistence query stringresultClass - the type of the query resultjava.lang.IllegalArgumentException - if the query string is found
to be invalidprotected DatabaseQuery createQueryInternal(Expression expression,
java.lang.Class resultType)
public StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName)
StoredProcedureQuery for executing a
stored procedure in the database.
Parameters must be registered before the stored procedure can be executed.
If the stored procedure returns one or more result sets, any result set will be returned as a list of type Object[].
procedureName - name of the stored procedure in the databasejava.lang.IllegalArgumentException - if a stored procedure of the given name
does not exist (or the query execution will fail)public StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName,
java.lang.Class... resultClasses)
StoredProcedureQuery for executing a
stored procedure in the database.
Parameters must be registered before the stored procedure can be executed.
The resultClass arguments must be specified in the order
in which the result sets will be returned by the stored procedure
invocation.
procedureName - name of the stored procedure in the databaseresultClasses - classes to which the result sets produced by the
stored procedure are to be mappedjava.lang.IllegalArgumentException - if a stored procedure of the given name
does not exist (or the query execution will fail)public StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName,
java.lang.String... resultSetMappings)
StoredProcedureQuery for executing a
stored procedure in the database.
Parameters must be registered before the stored procedure can be executed.
The resultSetMapping arguments must be specified in the
order in which the result sets will be returned by the stored procedure
invocation.
procedureName - name of the stored procedure in the databaseresultSetMappings - the names of the result set mappings
to be used in mapping result sets
returned by the stored procedurejava.lang.IllegalArgumentException - if a stored procedure or
result set mapping of the given name does not exist
(or the query execution will fail)public void close()
Closes this EntityManager.
After invoking this method, all methods on the instance will throw an
IllegalStateException except for isOpen, which will
return false .
This should be called when a method is finished with the EntityManager in a bean-managed transaction environment or when executed outside a container. Closing of the EntityManager is handled by the container when using container-managed transactions.
protected void closeOpenQueries()
public boolean isFlushModeAUTO()
public boolean isOpen()
true until a call to close() is made.public void lock(java.lang.Object entity,
LockModeType lockMode)
entity - lockMode - PersistenceException - if an unsupported lock call is madejava.lang.IllegalArgumentException - if the instance is not an entity or is a detached entityjavax.persistence.TransactionRequiredException - if there is no transactionpublic void lock(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
entity - lockMode - PersistenceException - if an unsupported lock call is madejava.lang.IllegalArgumentException - if the instance is not an entity or is a detached entityjavax.persistence.TransactionRequiredException - if there is no transactionpublic void verifyOpen()
public void verifyOpenWithSetRollbackOnly()
public RepeatableWriteUnitOfWork getActivePersistenceContext(java.lang.Object txn)
public void setProperties(java.util.Map properties)
public void setProperty(java.lang.String propertyName,
java.lang.Object value)
EntityManager#setProperty(java.lang.String, java.lang.Object)public boolean hasActivePersistenceContext()
protected java.lang.Object checkForTransaction(boolean validateExistence)
public boolean shouldFlushBeforeQuery()
public boolean shouldBeginEarlyTransaction()
public void joinTransaction()
javax.persistence.TransactionRequiredException - if there is no transaction.protected void setRollbackOnly()
protected void processProperties()
protected java.lang.String getPropertiesHandlerProperty(java.lang.String name)
protected static java.lang.String getPropertiesHandlerProperty(java.lang.String name,
java.lang.String value)
protected void setEntityTransactionWrapper()
public void setFlushMode(FlushModeType flushMode)
flushMode - protected void setJTATransactionWrapper()
protected void createConnectionPolicy()
protected void createConnectionPolicies(java.util.Map mapOfProperties)
protected static ConnectionPolicy createConnectionPolicy(ServerSession serverSession,
java.util.Map properties)
public boolean isBroker()
isBroker in interface JpaEntityManagerprotected static boolean isPropertyToBeAdded(java.lang.String value)
protected static boolean isPropertyToBeAdded(javax.sql.DataSource ds,
java.lang.String dsName)
protected static boolean isPropertyToBeRemoved(java.lang.String value)
protected static java.lang.Boolean isPropertyValueToBeUpdated(java.lang.String oldValue,
java.lang.String newValue)
public void detach(java.lang.Object entity)
entity - java.lang.IllegalArgumentException - if the instance is not an entitypublic CriteriaBuilder getCriteriaBuilder()
java.lang.IllegalStateException - if the entity manager has
been closed.javax.persistence.EntityManager#getCriteriaBuilder()protected java.util.HashMap<java.lang.String,java.lang.Object> getQueryHints(java.lang.Object entity,
EntityManagerImpl.OperationType operation)
public Metamodel getMetamodel()
java.lang.IllegalStateException - if the entity manager has
been closed.javax.persistence.EntityManager#getMetamodel()public EntityManagerFactory getEntityManagerFactory()
java.lang.IllegalStateException - if the entity manager has been closed.public LockModeType getLockMode(java.lang.Object entity)
javax.persistence.EntityManager#getLockMode(java.lang.Object)public java.util.Map<java.lang.String,java.lang.Object> getProperties()
public java.util.Set<java.lang.String> getSupportedProperties()
public <T> T unwrap(java.lang.Class<T> cls)
cls - the class of the object to be returned. This is normally
either the underlying EntityManager implementation class or an
interface that it implements.PersistenceException - if the provider does not support the call.public void load(java.lang.Object entityOrEntities,
AttributeGroup group)
load in interface JpaEntityManagerentityOrEntities - public java.lang.Object copy(java.lang.Object entityOrEntities,
AttributeGroup group)
copy in interface JpaEntityManagerentityOrEntities - public static void processUnfetchedAttribute(FetchGroupTracker entity,
java.lang.String attributeName)
public static void processUnfetchedAttributeForSet(FetchGroupTracker entity,
java.lang.String attributeName)
public Query createQuery(CriteriaUpdate updateQuery)
JpaEntityManagercreateQuery in interface JpaEntityManagerpublic Query createQuery(CriteriaDelete deleteQuery)
JpaEntityManagercreateQuery in interface JpaEntityManagerpublic boolean isJoinedToTransaction()
public <T> <any> createEntityGraph(java.lang.Class<T> rootType)
public EntityGraph createEntityGraph(java.lang.String graphName)
public EntityGraph getEntityGraph(java.lang.String graphName)
public <T> java.util.List<<any>> getEntityGraphs(java.lang.Class<T> entityClass)
public SynchronizationType getSyncType()