public class EntityManagerImpl extends 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.
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 UnitOfWork.CommitOrderType |
commitOrder
Allow updates to be ordered by id to avoid possible deadlocks.
|
protected boolean |
commitWithoutPersistRules |
protected Map<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 String |
flushClearCache
The FlashClearCache mode to be used.
|
protected jakarta.persistence.FlushModeType |
flushMode
Flush mode property, allows flush before query to be avoided.
|
protected boolean |
isOpen
Store if this entity manager has been closed.
|
protected 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 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 jakarta.persistence.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,
Map properties,
jakarta.persistence.SynchronizationType syncType)
Constructor called from the EntityManagerFactory to create an
EntityManager
|
EntityManagerImpl(AbstractSession databaseSession,
jakarta.persistence.SynchronizationType syncType)
Constructor called from the EntityManagerFactory to create an
EntityManager
|
EntityManagerImpl(EntityManagerFactoryDelegate factory,
Map properties,
jakarta.persistence.SynchronizationType syncType)
Constructor called from the EntityManagerFactory to create an
EntityManager
|
EntityManagerImpl(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 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(Object entity)
Check if the instance belongs to the current persistence context.
|
protected boolean |
contains(Object entity,
UnitOfWork uow)
Check if the instance belongs to the current persistence context.
|
Object |
copy(Object entityOrEntities,
AttributeGroup group)
This method will return copy the passed entity using the passed AttributeGroup.
|
protected void |
createConnectionPolicies(Map mapOfProperties)
Create connection policy using properties.
|
protected void |
createConnectionPolicy()
Create connection policy using properties.
|
protected static ConnectionPolicy |
createConnectionPolicy(ServerSession serverSession,
Map properties)
Create connection policy using properties.
|
jakarta.persistence.Query |
createDescriptorNamedQuery(String queryName,
Class descriptorClass)
This method will create a query object that wraps a EclipseLink Named Query.
|
jakarta.persistence.Query |
createDescriptorNamedQuery(String queryName,
Class descriptorClass,
List argumentTypes)
This method will create a query object that wraps a EclipseLink Named Query.
|
<T> jakarta.persistence.EntityGraph<T> |
createEntityGraph(Class<T> rootType) |
jakarta.persistence.EntityGraph |
createEntityGraph(String graphName) |
jakarta.persistence.Query |
createNamedQuery(String name)
Create an instance of Query for executing a named query (in EJBQL or
native SQL).
|
<T> jakarta.persistence.TypedQuery<T> |
createNamedQuery(String name,
Class<T> resultClass)
Create an instance of TypedQuery for executing a
named query (in the Java Persistence query language
or in native SQL).
|
jakarta.persistence.StoredProcedureQuery |
createNamedStoredProcedureQuery(String name)
Create an instance of StoredProcedureQuery for executing a
stored procedure in the database.
|
jakarta.persistence.Query |
createNativeQuery(String sqlString)
Create an instance of Query for executing a native SQL query.
|
jakarta.persistence.Query |
createNativeQuery(String sqlString,
Class resultType)
This method is used to create a query using SQL.
|
jakarta.persistence.Query |
createNativeQuery(String sqlString,
String resultSetMapping)
Create an instance of Query for executing a native SQL query.
|
jakarta.persistence.Query |
createQuery(Call call)
This method is used to create a query using a EclipseLink Call.
|
jakarta.persistence.Query |
createQuery(Call call,
Class entityClass)
This method is used to create a query using a EclipseLink Call.
|
jakarta.persistence.Query |
createQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery) |
<T> jakarta.persistence.TypedQuery<T> |
createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery) |
jakarta.persistence.Query |
createQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery) |
jakarta.persistence.Query |
createQuery(DatabaseQuery databaseQuery)
This method is used to create a query using a EclipseLink DatabaseQuery.
|
jakarta.persistence.Query |
createQuery(Expression expression,
Class resultType)
This method is used to create a query using a EclipseLink Expression and
the return type.
|
jakarta.persistence.Query |
createQuery(String jpqlString)
Create an instance of Query for executing an JPQL query.
|
<T> jakarta.persistence.TypedQuery<T> |
createQuery(String qlString,
Class<T> resultClass)
Create an instance of TypedQuery for executing a
Java Persistence query language statement.
|
jakarta.persistence.Query |
createQueryByExample(Object exampleObject)
This method is used to create a query using a EclipseLink by example.
|
protected DatabaseQuery |
createQueryInternal(Expression expression,
Class resultType)
This method is used to create a query using a EclipseLink Expression and
the return type.
|
jakarta.persistence.StoredProcedureQuery |
createStoredProcedureQuery(String procedureName)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
jakarta.persistence.StoredProcedureQuery |
createStoredProcedureQuery(String procedureName,
Class... resultClasses)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
jakarta.persistence.StoredProcedureQuery |
createStoredProcedureQuery(String procedureName,
String... resultSetMappings)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
void |
detach(Object entity)
Remove the given entity from the persistence context, causing a managed
entity to become detached.
|
protected void |
detectTransactionWrapper() |
<T> T |
find(Class<T> entityClass,
Object primaryKey)
Find by primary key.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
jakarta.persistence.LockModeType lockMode)
Find by primary key and lock.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
jakarta.persistence.LockModeType lockMode,
Map<String,Object> properties)
Find by primary key and lock.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
Map<String,Object> properties)
Find by primary key, using the specified properties.
|
Object |
find(String entityName,
Object primaryKey)
Find by primary key.
|
protected Object |
findInternal(ClassDescriptor descriptor,
AbstractSession session,
Object id,
jakarta.persistence.LockModeType lockMode,
Map<String,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(Object txn) |
Session |
getActiveSession()
This method returns the current session to the requestor.
|
AbstractSession |
getActiveSessionIfExists()
This method returns the current session to the requestor.
|
jakarta.persistence.criteria.CriteriaBuilder |
getCriteriaBuilder()
Return an instance of CriteriaBuilder for the creation of
Criteria API Query objects.
|
DatabaseSessionImpl |
getDatabaseSession()
Return the underlying database session
|
Object |
getDelegate()
Return the underlying provider object for the EntityManager, if
available.
|
jakarta.persistence.EntityGraph |
getEntityGraph(String graphName) |
<T> List<jakarta.persistence.EntityGraph<? super T>> |
getEntityGraphs(Class<T> entityClass) |
jakarta.persistence.EntityManagerFactory |
getEntityManagerFactory()
Return the entity manager factory for the entity manager.
|
jakarta.persistence.FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained in the
persistence context.
|
jakarta.persistence.LockModeType |
getLockMode(Object entity) |
DatabaseSessionImpl |
getMemberDatabaseSession(Class cls)
Return the member DatabaseSessionImpl that maps cls in session broker.
|
ServerSession |
getMemberServerSession(Class cls)
Return the member ServerSession that maps cls in session broker.
|
String |
getMemberSessionName(Class cls)
Return the name of member session that maps cls.
|
jakarta.persistence.metamodel.Metamodel |
getMetamodel()
Return an instance of Metamodel interface for access to the
metamodel of the persistence unit.
|
protected Map<QueryImpl,QueryImpl> |
getOpenQueriesMap()
Return the weak reference to the open queries.
|
protected Set<QueryImpl> |
getOpenQueriesSet()
Return the weak reference to the open queries.
|
Map<String,Object> |
getProperties()
Get the properties and associated values that are in effect for the
entity manager.
|
protected String |
getPropertiesHandlerProperty(String name)
Get the local EntityManager property from the properties Map.
|
protected static String |
getPropertiesHandlerProperty(String name,
String value)
Verifies and (if required) translates the value.
|
Object |
getProperty(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 HashMap<String,Object> |
getQueryHints(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(Class referenceClass,
Object primaryKey,
Map properties)
Build a selection query for the primary key values.
|
protected ReadObjectQuery |
getReadObjectQuery(Map properties)
Build a selection query using the given properties.
|
protected ReadObjectQuery |
getReadObjectQuery(Object entity,
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(Class<T> entityClass,
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.
|
Set<String> |
getSupportedProperties()
Get the names of the properties that are supported for use with the
entity manager.
|
jakarta.persistence.SynchronizationType |
getSyncType()
INTERNAL:
Tracks if this EntityManager should automatically associate with the transaction or not
|
jakarta.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(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(DataSource ds,
String dsName) |
protected static boolean |
isPropertyToBeAdded(String value)
Property value is to be added if it's non null and not an empty string.
|
protected static boolean |
isPropertyToBeRemoved(String value)
Property value of an empty string indicates that the existing property
should be removed.
|
protected static Boolean |
isPropertyValueToBeUpdated(String oldValue,
String newValue) |
void |
joinTransaction()
Indicate to the EntityManager that a JTA transaction is active.
|
void |
load(Object entityOrEntities,
AttributeGroup group)
This method will load the passed entity or collection of entities using the passed AttributeGroup.
|
void |
lock(Object entity,
jakarta.persistence.LockModeType lockMode)
Set the lock mode for an entity object contained in the persistence
context.
|
void |
lock(Object entity,
jakarta.persistence.LockModeType lockMode,
Map<String,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 Object |
mergeInternal(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(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,
String attributeName)
INTERNAL:
Load/fetch the unfetched object.
|
static void |
processUnfetchedAttributeForSet(FetchGroupTracker entity,
String attributeName)
INTERNAL:
Load/fetch the unfetched object.
|
void |
refresh(Object entity)
Refresh the state of the instance from the database.
|
void |
refresh(Object entity,
jakarta.persistence.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(Object entity,
jakarta.persistence.LockModeType lockMode,
Map<String,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(Object entity,
Map<String,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(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(jakarta.persistence.FlushModeType flushMode)
Set the flush mode that applies to all objects contained in the
persistence context.
|
protected void |
setJTATransactionWrapper() |
void |
setProperties(Map properties)
Use this method to set properties into existing EntityManager that are
normally passed to createEntityManager method.
|
void |
setProperty(String propertyName,
Object value) |
protected void |
setRollbackOnly()
Internal method.
|
boolean |
shouldBeginEarlyTransaction()
Indicate the early transaction should be forced to start.
|
boolean |
shouldFlushBeforeQuery() |
<T> T |
unwrap(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 Map properties
protected jakarta.persistence.FlushModeType flushMode
protected ReferenceMode referenceMode
protected ConnectionPolicy connectionPolicy
protected Map<String,ConnectionPolicy> connectionPolicies
protected WeakHashMap<QueryImpl,QueryImpl> openQueriesMap
protected boolean closeOnCommit
protected boolean persistOnCommit
protected boolean cacheStoreBypass
protected String flushClearCache
FlushClearCacheprotected boolean shouldValidateExistence
protected UnitOfWork.CommitOrderType commitOrder
protected boolean commitWithoutPersistRules
protected jakarta.persistence.SynchronizationType syncType
public EntityManagerImpl(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, jakarta.persistence.SynchronizationType syncType)
databaseSession - the databaseSession assigned to this deployment.public EntityManagerImpl(AbstractSession databaseSession, Map properties, jakarta.persistence.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, Map properties, jakarta.persistence.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 Map<QueryImpl,QueryImpl> getOpenQueriesMap()
protected Set<QueryImpl> getOpenQueriesSet()
public void addOpenQuery(QueryImpl query)
query - protected void initialize(Map properties)
public void clear()
clear in interface jakarta.persistence.EntityManagerpublic void removeExtendedPersistenceContext()
public void persist(Object entity)
persist in interface jakarta.persistence.EntityManagerentity - IllegalArgumentException - if the given Object is not an entity.public <T> T merge(T entity)
merge in interface jakarta.persistence.EntityManagerentity - protected Object mergeInternal(Object entity)
entity - IllegalArgumentException - if given Object is not an entity or is a removed entitypublic void remove(Object entity)
remove in interface jakarta.persistence.EntityManagerentity - IllegalArgumentException - if Object passed in is not an entitypublic <T> T find(Class<T> entityClass, Object primaryKey)
find in interface jakarta.persistence.EntityManagerentityClass - - the entity class to find.primaryKey - - the entity primary key value, or primary key class, or a
List of primary key values.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(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
find in interface jakarta.persistence.EntityManagerentityClass - primaryKey - properties - standard and vendor-specific propertiesIllegalArgumentException - 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(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lockMode)
find in interface jakarta.persistence.EntityManagerentityClass - primaryKey - lockMode - 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 nulljakarta.persistence.TransactionRequiredException - if there is no transaction and a lock mode other than NONE is
setjakarta.persistence.OptimisticLockException - if the optimistic version check failsjakarta.persistence.PessimisticLockException - if pessimistic locking fails and the transaction is rolled
backjakarta.persistence.LockTimeoutException - if pessimistic locking fails and only the statement is rolled
backjakarta.persistence.PersistenceException - if an unsupported lock call is madepublic <T> T find(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)
find in interface jakarta.persistence.EntityManagerentityClass - primaryKey - lockMode - properties - standard and vendor-specific properties and hintsIllegalArgumentException - 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 nulljakarta.persistence.TransactionRequiredException - if there is no transaction and a lock mode other than NONE is
setjakarta.persistence.OptimisticLockException - if the optimistic version check failsjakarta.persistence.PessimisticLockException - if pessimistic locking fails and the transaction is rolled
backjakarta.persistence.LockTimeoutException - if pessimistic locking fails and only the statement is rolled
backjakarta.persistence.PersistenceException - if an unsupported lock call is madepublic Object find(String entityName, 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.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 Object findInternal(ClassDescriptor descriptor, AbstractSession session, Object id, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)
descriptor - - the entity class to find.id - - the entity primary key value, or primary key class, or a
List of primary key values.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()
flush in interface jakarta.persistence.EntityManagerprotected void detectTransactionWrapper()
public void refresh(Object entity)
refresh in interface jakarta.persistence.EntityManagerentity - instance registered in the current persistence context.public void refresh(Object entity, Map<String,Object> properties)
refresh in interface jakarta.persistence.EntityManagerentity - properties - standard and vendor-specific propertiesIllegalArgumentException - if the instance is not an entity or the entity is not managedjakarta.persistence.TransactionRequiredException - if invoked on a container-managed entity manager of type
PersistenceContextType.TRANSACTION and there is no
transaction.jakarta.persistence.EntityNotFoundException - if the entity no longer exists in the databasepublic void refresh(Object entity, jakarta.persistence.LockModeType lockMode)
refresh in interface jakarta.persistence.EntityManagerentity - lockMode - IllegalArgumentException - if the instance is not an entity or the entity is not managedjakarta.persistence.TransactionRequiredException - if there is no transactionjakarta.persistence.EntityNotFoundException - if the entity no longer exists in the databasejakarta.persistence.PessimisticLockException - if pessimistic locking fails and the transaction is rolled
backjakarta.persistence.LockTimeoutException - if pessimistic locking fails and only the statement is rolled
backjakarta.persistence.PersistenceException - if an unsupported lock call is madepublic void refresh(Object entity, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)
refresh in interface jakarta.persistence.EntityManagerentity - lockMode - properties - standard and vendor-specific properties and hintsIllegalArgumentException - if the instance is not an entity or the entity is not managedjakarta.persistence.TransactionRequiredException - if there is no transactionjakarta.persistence.EntityNotFoundException - if the entity no longer exists in the databasejakarta.persistence.PessimisticLockException - if pessimistic locking fails and the transaction is rolled
backjakarta.persistence.LockTimeoutException - if pessimistic locking fails and only the statement is rolled
backjakarta.persistence.PersistenceException - if an unsupported lock call is madepublic boolean contains(Object entity)
contains in interface jakarta.persistence.EntityManagerentity - IllegalArgumentException - if given Object is not an entityprotected boolean contains(Object entity, UnitOfWork uow)
public jakarta.persistence.Query createDescriptorNamedQuery(String queryName, Class descriptorClass)
JpaEntityManagercreateDescriptorNamedQuery in interface JpaEntityManagerpublic jakarta.persistence.Query createDescriptorNamedQuery(String queryName, Class descriptorClass, List argumentTypes)
JpaEntityManagercreateDescriptorNamedQuery in interface JpaEntityManagerpublic jakarta.persistence.Query createNamedQuery(String name)
createNamedQuery in interface jakarta.persistence.EntityManagername - the name of a query defined in metadatapublic <T> jakarta.persistence.TypedQuery<T> createNamedQuery(String name, Class<T> resultClass)
createNamedQuery in interface jakarta.persistence.EntityManagername - the name of a query defined in metadataresultClass - the type of the query resultIllegalArgumentException - if a query has not been
defined with the given name or if the query string is
found to be invalidpublic jakarta.persistence.StoredProcedureQuery createNamedStoredProcedureQuery(String name)
createNamedStoredProcedureQuery in interface jakarta.persistence.EntityManagername - name assigned to the stored procedure query
in metadataIllegalArgumentException - if a query has not been
defined with the given namepublic jakarta.persistence.Query createNativeQuery(String sqlString)
createNativeQuery in interface jakarta.persistence.EntityManagersqlString - a native SQL query stringpublic jakarta.persistence.Query createNativeQuery(String sqlString, Class resultType)
createNativeQuery in interface jakarta.persistence.EntityManagerpublic jakarta.persistence.Query createNativeQuery(String sqlString, String resultSetMapping)
createNativeQuery in interface jakarta.persistence.EntityManagersqlString - a native SQL query stringresultSetMapping - the name of the result set mappingIllegalArgumentException - if query string is not validpublic Session getActiveSession()
getActiveSession in interface JpaEntityManagerpublic AbstractSession getActiveSessionIfExists()
public Object getDelegate()
getDelegate in interface jakarta.persistence.EntityManagerpublic jakarta.persistence.FlushModeType getFlushMode()
getFlushMode in interface jakarta.persistence.EntityManagerpublic UnitOfWork getUnitOfWork()
getUnitOfWork in interface JpaEntityManagerpublic Session getSession()
getSession in interface JpaEntityManagerpublic jakarta.persistence.EntityTransaction getTransaction()
getTransaction in interface jakarta.persistence.EntityManagerIllegalStateException - if invoked on a JTA EntityManager.public Object getProperty(String name)
name - protected ReadObjectQuery getReadObjectQuery(Class referenceClass, Object primaryKey, Map properties)
protected ReadObjectQuery getReadObjectQuery(Map properties)
protected ReadObjectQuery getReadObjectQuery(Object entity, Map properties)
public <T> T getReference(Class<T> entityClass, Object primaryKey)
getReference in interface jakarta.persistence.EntityManagerentityClass - primaryKey - 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.jakarta.persistence.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(Class cls)
getMemberDatabaseSession in interface JpaEntityManagerpublic ServerSession getMemberServerSession(Class cls)
getMemberServerSession in interface JpaEntityManagerpublic String getMemberSessionName(Class cls)
getMemberSessionName in interface JpaEntityManagerpublic jakarta.persistence.Query createQuery(Expression expression, Class resultType)
createQuery in interface JpaEntityManagerpublic jakarta.persistence.Query createQuery(DatabaseQuery databaseQuery)
createQuery in interface JpaEntityManagerpublic <T> jakarta.persistence.TypedQuery<T> createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)
createQuery in interface jakarta.persistence.EntityManagerEntityManager.createQuery(jakarta.persistence.criteria.CriteriaQuery)public jakarta.persistence.Query createQueryByExample(Object exampleObject)
createQueryByExample in interface JpaEntityManagerpublic jakarta.persistence.Query createQuery(Call call)
createQuery in interface JpaEntityManagerpublic jakarta.persistence.Query createQuery(Call call, Class entityClass)
createQuery in interface JpaEntityManagerpublic jakarta.persistence.Query createQuery(String jpqlString)
createQuery in interface jakarta.persistence.EntityManagerjpqlString - an JPQL query stringpublic <T> jakarta.persistence.TypedQuery<T> createQuery(String qlString, Class<T> resultClass)
createQuery in interface jakarta.persistence.EntityManagerqlString - a Java Persistence query stringresultClass - the type of the query resultIllegalArgumentException - if the query string is found
to be invalidprotected DatabaseQuery createQueryInternal(Expression expression, Class resultType)
public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(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[].
createStoredProcedureQuery in interface jakarta.persistence.EntityManagerprocedureName - name of the stored procedure in the databaseIllegalArgumentException - if a stored procedure of the given name
does not exist (or the query execution will fail)public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, 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.
createStoredProcedureQuery in interface jakarta.persistence.EntityManagerprocedureName - name of the stored procedure in the databaseresultClasses - classes to which the result sets produced by the
stored procedure are to be mappedIllegalArgumentException - if a stored procedure of the given name
does not exist (or the query execution will fail)public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, 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.
createStoredProcedureQuery in interface jakarta.persistence.EntityManagerprocedureName - 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 procedureIllegalArgumentException - 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.
close in interface jakarta.persistence.EntityManagerprotected void closeOpenQueries()
public boolean isFlushModeAUTO()
public boolean isOpen()
true until a call to close() is made.isOpen in interface jakarta.persistence.EntityManagerpublic void lock(Object entity, jakarta.persistence.LockModeType lockMode)
lock in interface jakarta.persistence.EntityManagerentity - lockMode - jakarta.persistence.PersistenceException - if an unsupported lock call is madeIllegalArgumentException - if the instance is not an entity or is a detached entityjakarta.persistence.TransactionRequiredException - if there is no transactionpublic void lock(Object entity, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)
lock in interface jakarta.persistence.EntityManagerentity - lockMode - jakarta.persistence.PersistenceException - if an unsupported lock call is madeIllegalArgumentException - if the instance is not an entity or is a detached entityjakarta.persistence.TransactionRequiredException - if there is no transactionpublic void verifyOpen()
public void verifyOpenWithSetRollbackOnly()
public RepeatableWriteUnitOfWork getActivePersistenceContext(Object txn)
public void setProperties(Map properties)
public void setProperty(String propertyName, Object value)
setProperty in interface jakarta.persistence.EntityManagerEntityManager.setProperty(java.lang.String, java.lang.Object)public boolean hasActivePersistenceContext()
protected Object checkForTransaction(boolean validateExistence)
public boolean shouldFlushBeforeQuery()
public boolean shouldBeginEarlyTransaction()
public void joinTransaction()
joinTransaction in interface jakarta.persistence.EntityManagerjakarta.persistence.TransactionRequiredException - if there is no transaction.protected void setRollbackOnly()
protected void processProperties()
protected String getPropertiesHandlerProperty(String name)
protected static String getPropertiesHandlerProperty(String name, String value)
protected void setEntityTransactionWrapper()
public void setFlushMode(jakarta.persistence.FlushModeType flushMode)
setFlushMode in interface jakarta.persistence.EntityManagerflushMode - protected void setJTATransactionWrapper()
protected void createConnectionPolicy()
protected void createConnectionPolicies(Map mapOfProperties)
protected static ConnectionPolicy createConnectionPolicy(ServerSession serverSession, Map properties)
public boolean isBroker()
isBroker in interface JpaEntityManagerprotected static boolean isPropertyToBeAdded(String value)
protected static boolean isPropertyToBeAdded(DataSource ds, String dsName)
protected static boolean isPropertyToBeRemoved(String value)
protected static Boolean isPropertyValueToBeUpdated(String oldValue, String newValue)
public void detach(Object entity)
detach in interface jakarta.persistence.EntityManagerentity - IllegalArgumentException - if the instance is not an entitypublic jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
getCriteriaBuilder in interface jakarta.persistence.EntityManagerIllegalStateException - if the entity manager has
been closed.EntityManager.getCriteriaBuilder()protected HashMap<String,Object> getQueryHints(Object entity, EntityManagerImpl.OperationType operation)
public jakarta.persistence.metamodel.Metamodel getMetamodel()
getMetamodel in interface jakarta.persistence.EntityManagerIllegalStateException - if the entity manager has
been closed.EntityManager.getMetamodel()public jakarta.persistence.EntityManagerFactory getEntityManagerFactory()
getEntityManagerFactory in interface jakarta.persistence.EntityManagerIllegalStateException - if the entity manager has been closed.public jakarta.persistence.LockModeType getLockMode(Object entity)
getLockMode in interface jakarta.persistence.EntityManagerEntityManager.getLockMode(java.lang.Object)public Map<String,Object> getProperties()
getProperties in interface jakarta.persistence.EntityManagerpublic Set<String> getSupportedProperties()
public <T> T unwrap(Class<T> cls)
unwrap in interface jakarta.persistence.EntityManagercls - the class of the object to be returned. This is normally
either the underlying EntityManager implementation class or an
interface that it implements.jakarta.persistence.PersistenceException - if the provider does not support the call.public void load(Object entityOrEntities, AttributeGroup group)
load in interface JpaEntityManagerentityOrEntities - public Object copy(Object entityOrEntities, AttributeGroup group)
copy in interface JpaEntityManagerentityOrEntities - public static void processUnfetchedAttribute(FetchGroupTracker entity, String attributeName)
public static void processUnfetchedAttributeForSet(FetchGroupTracker entity, String attributeName)
public jakarta.persistence.Query createQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)
createQuery in interface jakarta.persistence.EntityManagerpublic jakarta.persistence.Query createQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)
createQuery in interface jakarta.persistence.EntityManagerpublic boolean isJoinedToTransaction()
isJoinedToTransaction in interface jakarta.persistence.EntityManagerpublic <T> jakarta.persistence.EntityGraph<T> createEntityGraph(Class<T> rootType)
createEntityGraph in interface jakarta.persistence.EntityManagerpublic jakarta.persistence.EntityGraph createEntityGraph(String graphName)
createEntityGraph in interface jakarta.persistence.EntityManagerpublic jakarta.persistence.EntityGraph getEntityGraph(String graphName)
getEntityGraph in interface jakarta.persistence.EntityManagerpublic <T> List<jakarta.persistence.EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
getEntityGraphs in interface jakarta.persistence.EntityManagerpublic jakarta.persistence.SynchronizationType getSyncType()
Copyright © 2007–2021 Eclipse.org - EclipseLink Project. All rights reserved.