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.
jakarta.persistence.EntityManager , org.eclipse.persistence.jpa.JpaEntityManager
| Modifier and Type | Class and Description |
|---|---|
| protected static enum | |
| pack-priv abstract static class |
| 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. | commitOrder
Allow updates to be ordered by id to avoid possible deadlocks. |
| protected boolean | |
| protected Map | 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 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 | 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. |
| pack-priv static Map | |
| 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 SynchronizationType | syncType
Tracks if this EntityManager should automatically associate with the transaction or not |
| private TransactionWrapperImpl | transaction
Allows transparent transactions across JTA and local transactions. |
| Access | Constructor and Description |
|---|---|
| public | EntityManagerImpl(String
the DatabaseSession name that should be used. This constructor
can potentially throw EclipseLink exceptions regarding the
existence, or errors with the specified session. sessionName)Constructor returns an EntityManager assigned to the a particular DatabaseSession. |
| public | EntityManagerImpl(AbstractSession
the databaseSession assigned to this deployment. databaseSession, SynchronizationType syncType)Constructor called from the EntityManagerFactory to create an EntityManager |
| public | EntityManagerImpl(AbstractSession
the databaseSession assigned to this deployment. databaseSession, Map<K, V> properties, SynchronizationType syncType)Note The properties argument is provided to allow properties to be passed into this EntityManager, but there are currently no such properties implemented Constructor called from the EntityManagerFactory to create an EntityManager |
| public | EntityManagerImpl(EntityManagerFactoryDelegate
the EntityMangerFactoryImpl that created this entity manager.
factory, Map<K, V> properties, SynchronizationType syncType)Note The properties argument is provided to allow properties to be passed into this EntityManager, but there are currently no such properties implemented Constructor called from the EntityManagerFactory to create an EntityManager |
| Modifier and Type | Method and Description |
|---|---|
| public void | addOpenQuery(QueryImpl query)
Queries that leave the connection and are executed against this entity manager will be added here. |
| protected Object | |
| public void | clear()
Implements jakarta. |
| public void | close()
Implements jakarta. Closes this EntityManager. |
| protected void | |
| public boolean | contains(Object
entity instance entity)Implements jakarta. |
| protected boolean | contains(Object entity, UnitOfWork uow)
Check if the instance belongs to the current persistence context. |
| public Object | copy(Object entityOrEntities, AttributeGroup group)
Implements org. |
| protected void | |
| protected void | |
| protected static ConnectionPolicy | createConnectionPolicy(ServerSession serverSession, Map<K, V> properties)
Create connection policy using properties. |
| public Query | createDescriptorNamedQuery(String queryName, Class<?> descriptorClass)
Implements org. |
| public Query | createDescriptorNamedQuery(String queryName, Class<?> descriptorClass, List<E> argumentTypes)
Implements org. |
| public <T> EntityGraph | createEntityGraph(Class<T>
class of entity graph rootType)Implements jakarta. |
| public EntityGraph | createEntityGraph(String
name of an entity graph graphName)Implements jakarta. |
| public Query | Returns: the new query instancethe name of a query defined in metadata name)Implements jakarta. |
| public <T> TypedQuery | Returns: the new query instancethe name of a query defined in metadata name, Class<T> the type of the query result resultClass)Implements jakarta. |
| public StoredProcedureQuery | Returns: the new stored procedure query instancename assigned to the stored procedure query
in metadata name)Implements jakarta. |
| public Query | Returns: the new query instancea native SQL query string sqlString)Implements jakarta. |
| public Query | createNativeQuery(String
a native SQL query string sqlString, Class<T> the class of the resulting instance(s) resultType)Implements jakarta. |
| public Query | Returns: the new query instancea native SQL query string sqlString, String the name of the result set mapping resultSetMapping)Implements jakarta. |
| public Query | createQuery(Expression expression, Class<?> resultType)
Implements org. |
| public Query | createQuery(DatabaseQuery databaseQuery)
Implements org. |
| public <T> TypedQuery | createQuery(CriteriaQuery<T>
a criteria query object criteriaQuery)Implements jakarta. TypedQuery for executing a
criteria query.
|
| public Query | createQuery(Call call)
Implements org. |
| public Query | createQuery(Call call, Class<?> entityClass)
Implements org. |
| public Query | Returns: the new query instancean JPQL query string jpqlString)Implements jakarta. |
| public <T> TypedQuery | Returns: the new query instancea Java Persistence query string qlString, Class<T> the type of the query result resultClass)Implements jakarta. |
| public Query | createQuery(CriteriaUpdate<T>
a criteria update query object updateQuery)Implements jakarta. Query for executing a criteria
update query.
|
| public Query | createQuery(CriteriaDelete<T>
a criteria delete query object deleteQuery)Implements jakarta. Query for executing a criteria
delete query.
|
| public Query | createQueryByExample(Object exampleObject)
Implements org. |
| protected DatabaseQuery | createQueryInternal(Expression expression, Class<?> resultType)
This method is used to create a query using a EclipseLink Expression and the return type. |
| public StoredProcedureQuery | Returns: the new stored procedure query instancename of the stored procedure in the database procedureName)Implements jakarta. StoredProcedureQuery for executing a
stored procedure in the database.
|
| public StoredProcedureQuery | Returns: the new stored procedure query instancename of the stored procedure in the database procedureName, Class<T>... classes to which the result sets produced by the
stored procedure are to be mapped resultClasses)Implements jakarta. StoredProcedureQuery for executing a
stored procedure in the database.
|
| public StoredProcedureQuery | Returns: the new stored procedure query instancename of the stored procedure in the database procedureName, String... the names of the result set mappings
to be used in mapping result sets
returned by the stored procedure resultSetMappings)Implements jakarta. StoredProcedureQuery for executing a
stored procedure in the database.
|
| public void | detach(Object
entity instance entity)Implements jakarta. |
| protected void | |
| private Object | executeQuery(ReadObjectQuery query, LockModeType lockMode, AbstractSession session)
Execute the locking query. |
| public <T> T | Returns: the found entity instance or null if the entity does not exist- the entity class to find. entityClass, Object - the entity primary key value, or primary key class, or a
List of primary key values. primaryKey)Implements jakarta. |
| public <T> T | Returns: the found entity instance or null if the entity does not existentity class entityClass, Object primary key primaryKey, Map<String, Object> standard and vendor-specific properties properties)Implements jakarta. |
| public <T> T | Returns: the found entity instance or null if the entity does not existentity class entityClass, Object primary key primaryKey, LockModeType lock mode lockMode)Implements jakarta. |
| public <T> T | Returns: the found entity instance or null if the entity does not existentity class entityClass, Object primary key primaryKey, LockModeType lock mode lockMode, Map<String, Object> standard and vendor-specific properties and hints properties)Implements jakarta. |
| public Object | |
| protected Object | Returns: the found entity instance or null, if the entity does not exist.- the entity class to find. descriptor, AbstractSession session, Object - the entity primary key value, or primary key class, or a
List of primary key values. id, LockModeType lockMode, Map<String, Object> properties)Find by primary key. |
| public void | flush()
Implements jakarta. |
| public AbstractSession | getAbstractSession()
Implements org. |
| public RepeatableWriteUnitOfWork | |
| public Session | getActiveSession()
Implements org. |
| public AbstractSession | |
| public CriteriaBuilder | Returns: CriteriaBuilder instanceImplements jakarta. |
| public DatabaseSessionImpl | getDatabaseSession()
Implements org. |
| public Object | getDelegate()
Implements jakarta. |
| public EntityGraph | getEntityGraph(String
name of an existing entity graph graphName)Implements jakarta. |
| public <T> List | getEntityGraphs(Class<T>
entity class entityClass)Implements jakarta. |
| public EntityManagerFactory | Returns: EntityManagerFactory instanceImplements jakarta. |
| public FlushModeType | Returns: flushModeImplements jakarta. |
| public LockModeType | getLockMode(Object
entity instance entity)Implements jakarta. |
| public DatabaseSessionImpl | getMemberDatabaseSession(Class<?> cls)
Implements org. |
| public ServerSession | getMemberServerSession(Class<?> cls)
Implements org. |
| public String | getMemberSessionName(Class<?> cls)
Implements org. |
| public Metamodel | Returns: Metamodel instanceImplements jakarta. |
| protected Map | |
| protected Set | |
| public Map | getProperties()
Implements jakarta. |
| 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. |
| public 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 | getQueryHints(Object entity, EntityManagerImpl.
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<K, V> properties)
Build a selection query for the primary key values. |
| protected ReadObjectQuery | |
| protected ReadObjectQuery | getReadObjectQuery(Object entity, Map<K, V> properties)
Build a selection query for the given entity. |
| public Session | |
| public <T> T | Returns: the found entity instance.entity class entityClass, Object primary key primaryKey)Implements jakarta. |
| public ServerSession | getServerSession()
Implements org. |
| public Session | getSession()
Implements org. |
| public SessionBroker | getSessionBroker()
Implements org. |
| public Set | Returns: property namesGet the names of the properties that are supported for use with the entity manager. |
| public SynchronizationType | Returns: the syncTypeINTERNAL: Tracks if this EntityManager should automatically associate with the transaction or not |
| public EntityTransaction | Returns: EntityTransaction instanceImplements jakarta. |
| public UnitOfWork | getUnitOfWork()
Implements org. |
| public boolean | hasActivePersistenceContext()
This method is used in contains to check if we already have a persistence context. |
| protected void | |
| public boolean | isBroker()
Implements org. |
| public boolean | |
| public boolean | isJoinedToTransaction()
Implements jakarta. |
| public boolean | isOpen()
Implements jakarta. |
| 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 | |
| protected static boolean | isPropertyToBeRemoved(String value)
Property value of an empty string indicates that the existing property should be removed. |
| protected static Boolean | Returns: null: no change; TRUE: substitute oldValue by newValue; FALSE: remove oldValue
|
| public void | joinTransaction()
Implements jakarta. |
| public void | load(Object entityOrEntities, AttributeGroup group)
Implements org. |
| public void | lock(Object
entity instance entity, LockModeType lock mode lockMode)Implements jakarta. |
| public void | lock(Object
entity instance entity, LockModeType lock mode lockMode, Map<String, Object> standard and vendor-specific properties
and hints properties)Implements jakarta. |
| public <T> T | Returns: the instance that the state was merged toentity instance entity)Implements jakarta. |
| protected Object | Returns: the instance that the state was merged toMerge the state of the given entity into the current persistence context, using the unqualified class name as the entity name. |
| public void | persist(Object
entity instance entity)Implements jakarta. |
| protected void | |
| public static void | processUnfetchedAttribute(FetchGroupTracker entity, String attributeName)
INTERNAL: Load/fetch the unfetched object. |
| public static void | processUnfetchedAttributeForSet(FetchGroupTracker entity, String attributeName)
INTERNAL: Load/fetch the unfetched object. |
| public void | refresh(Object
instance registered in the current persistence context. entity)Implements jakarta. |
| public void | |
| public void | refresh(Object
entity instance entity, LockModeType lock mode lockMode)Implements jakarta. |
| public void | refresh(Object
entity instance entity, LockModeType lock mode lockMode, Map<String, Object> standard and vendor-specific properties and hints properties)Implements jakarta. |
| public void | remove(Object
entity instance entity)Implements jakarta. |
| public void | removeExtendedPersistenceContext()
Internal method called by EntityTransactionImpl class in case of transaction rollback. |
| public void | |
| protected void | |
| public void | setFlushMode(FlushModeType
flush mode flushMode)Implements jakarta. |
| protected void | |
| public void | setProperties(Map<K, V> properties)
Use this method to set properties into existing EntityManager that are normally passed to createEntityManager method. |
| public void | setProperty(String
name of property or hint propertyName, Object value for property or hint value)Implements jakarta. |
| protected void | |
| public boolean | |
| public boolean | |
| public <T> T | Returns: an instance of the specified classthe class of the object to be returned. This is normally
either the underlying EntityManager implementation class or an
interface that it implements. cls)Implements jakarta. |
| public void | |
| public void | verifyOpenWithSetRollbackOnly()
used to save having to constantly use a try/catch to call setRollbackOnly |