Package org.datanucleus.api.jakarta
Class JakartaEntityManager
- java.lang.Object
-
- org.datanucleus.api.jakarta.JakartaEntityManager
-
- All Implemented Interfaces:
jakarta.persistence.EntityManager
,AutoCloseable
public class JakartaEntityManager extends Object implements jakarta.persistence.EntityManager
EntityManager implementation for Jakarta Persistence.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
closed
protected org.datanucleus.ExecutionContext
ec
The underlying ExecutionContext managing the persistence.protected JakartaEntityManagerFactory
emf
Parent EntityManagerFactory.protected JakartaFetchPlan
fetchPlan
Fetch Plan (extension).protected jakarta.persistence.FlushModeType
flushMode
The Flush Mode.protected jakarta.persistence.PersistenceContextType
persistenceContextType
Type of Persistence Contextprotected jakarta.persistence.SynchronizationType
syncType
protected jakarta.persistence.EntityTransaction
tx
Current Transaction (when using ResourceLocal).
-
Constructor Summary
Constructors Constructor Description JakartaEntityManager(JakartaEntityManagerFactory theEMF, org.datanucleus.PersistenceNucleusContext nucleusCtx, jakarta.persistence.PersistenceContextType contextType, jakarta.persistence.SynchronizationType syncType)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the persistence context, causing all managed entities to become detached.void
close()
Close an (application-managed) EntityManager.boolean
contains(Object entity)
Check if the instance belongs to the current persistence context.<T> jakarta.persistence.EntityGraph<T>
createEntityGraph(Class<T> rootType)
jakarta.persistence.EntityGraph<?>
createEntityGraph(String graphName)
JakartaQuery
createNamedQuery(String queryName)
Create an instance of Query for executing a named query (in JPQL or native).<T> jakarta.persistence.TypedQuery<T>
createNamedQuery(String queryName, Class<T> resultClass)
Create an instance of Query for executing a named query (in JPQL or native).jakarta.persistence.StoredProcedureQuery
createNamedStoredProcedureQuery(String procName)
Create an instance of Query for executing a stored procedure.jakarta.persistence.Query
createNativeQuery(String queryString)
Create an instance of Query for executing a native query statement.jakarta.persistence.Query
createNativeQuery(String queryString, Class resultClass)
Create an instance of Query for executing a "native" query.jakarta.persistence.Query
createNativeQuery(String queryString, String resultSetMapping)
Create an instance of Query for executing a native query.jakarta.persistence.Query
createQuery(jakarta.persistence.criteria.CriteriaDelete crit)
<T> jakarta.persistence.TypedQuery<T>
createQuery(jakarta.persistence.criteria.CriteriaQuery<T> cq)
Method to return a query for the specified Criteria Query.jakarta.persistence.Query
createQuery(jakarta.persistence.criteria.CriteriaUpdate crit)
JakartaQuery
createQuery(String queryString)
Create an instance of Query for executing a JPQL statement.<T> jakarta.persistence.TypedQuery<T>
createQuery(String queryString, Class<T> resultClass)
jakarta.persistence.StoredProcedureQuery
createStoredProcedureQuery(String procName)
Create an instance of Query for executing a stored procedure.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.void
detach(Object... entities)
void
detach(Collection entities)
<T> T
find(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lock)
<T> T
find(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lock, Map<String,Object> properties)
Method to return the persistent object of the specified entity type with the provided PK.<T> T
find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
Find by primary key, using the specified properties.Object
find(Class entityClass, Object primaryKey)
Method to find an object from its primary key.<T> T
findByUnique(Class<T> cls, String[] fieldNames, Object[] fieldValues)
Method to look up the instance of the given type with the given key.void
flush()
Synchronize the persistence context to the underlying database.jakarta.persistence.criteria.CriteriaBuilder
getCriteriaBuilder()
Return an instance of QueryBuilder for the creation of Criteria API QueryDefinition objects.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.org.datanucleus.ExecutionContext
getExecutionContext()
JakartaFetchPlan
getFetchPlan()
Acessor for the current FetchPlanjakarta.persistence.FlushModeType
getFlushMode()
Get the flush mode that applies to all objects contained in the persistence context.static jakarta.persistence.LockModeType
getJakartaLockModeTypeForLockMode(org.datanucleus.state.LockMode lockMode)
Convenience method to convert from LockManager lock type to Jakarta Persistence LockModeTypejakarta.persistence.LockModeType
getLockMode(Object entity)
Get the current lock mode for the entity instance.static org.datanucleus.state.LockMode
getLockModeForJakartaLockModeType(jakarta.persistence.LockModeType lock)
Convenience method to convert from the Jakarta Persistence LockModeType to the internal lock mode.jakarta.persistence.metamodel.Metamodel
getMetamodel()
Return an instance of Metamodel interface for access to the metamodel of the persistence unit.Map<String,Object>
getProperties()
Get the properties and associated values that are in effect for the entity manager.Object
getReference(Class entityClass, Object primaryKey)
Get an instance, whose state may be lazily fetched.Set<String>
getSupportedProperties()
Get the names of the properties that are supported for use with the entity manager.jakarta.persistence.EntityTransaction
getTransaction()
Return the resource-level transaction object.boolean
isContainerManaged()
boolean
isJoinedToTransaction()
Return whether this EntityManager is joined to the current transaction.boolean
isOpen()
Determine whether the EntityManager is open.boolean
isTransactionActive()
void
joinTransaction()
Indicate to the EntityManager that a JTA transaction is active so join to it.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 lock, Map<String,Object> properties)
Set the lock mode for an entity object contained in the persistence context.Object
merge(Object entity)
Merge the state of the given entity into the current persistence context.Object[]
merge(Object... entities)
Collection
merge(Collection entities)
void
persist(Object entity)
Make an instance managed and persistent.void
persist(Object... entities)
void
persist(Collection entities)
void
refresh(Object entity)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.void
refresh(Object entity, jakarta.persistence.LockModeType lock)
void
refresh(Object entity, jakarta.persistence.LockModeType lock, Map<String,Object> properties)
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 entity instance.void
remove(Object... entities)
void
remove(Collection entities)
void
setFlushMode(jakarta.persistence.FlushModeType flushMode)
Set the flush mode that applies to all objects contained in the persistence context.void
setProperty(String propertyName, Object value)
Set an entity manager property.<T> T
unwrap(Class<T> cls)
Return an object of the specified type to allow access to the provider-specific API.
-
-
-
Field Detail
-
closed
protected boolean closed
-
ec
protected org.datanucleus.ExecutionContext ec
The underlying ExecutionContext managing the persistence.
-
emf
protected JakartaEntityManagerFactory emf
Parent EntityManagerFactory.
-
tx
protected jakarta.persistence.EntityTransaction tx
Current Transaction (when using ResourceLocal). Will be null if using JTA.
-
flushMode
protected jakarta.persistence.FlushModeType flushMode
The Flush Mode.
-
persistenceContextType
protected jakarta.persistence.PersistenceContextType persistenceContextType
Type of Persistence Context
-
syncType
protected jakarta.persistence.SynchronizationType syncType
-
fetchPlan
protected JakartaFetchPlan fetchPlan
Fetch Plan (extension).
-
-
Constructor Detail
-
JakartaEntityManager
public JakartaEntityManager(JakartaEntityManagerFactory theEMF, org.datanucleus.PersistenceNucleusContext nucleusCtx, jakarta.persistence.PersistenceContextType contextType, jakarta.persistence.SynchronizationType syncType)
Constructor.- Parameters:
theEMF
- The parent EntityManagerFactorynucleusCtx
- Nucleus ContextcontextType
- The Persistence Context typesyncType
- The Synchronisation type
-
-
Method Detail
-
clear
public void clear()
Clear the persistence context, causing all managed entities to become detached. Changes made to entities that have not been flushed to the database will not be persisted.- Specified by:
clear
in interfacejakarta.persistence.EntityManager
-
isContainerManaged
public boolean isContainerManaged()
-
isOpen
public boolean isOpen()
Determine whether the EntityManager is open.- Specified by:
isOpen
in interfacejakarta.persistence.EntityManager
- Returns:
- true until the EntityManager has been closed.
-
getExecutionContext
public org.datanucleus.ExecutionContext getExecutionContext()
-
close
public void close()
Close an (application-managed) EntityManager. After the close method has been invoked, all methods on the EntityManager instance and any Query objects obtained from it will throw the IllegalStateException except for getTransaction and isOpen (which will return false). If this method is called when the EntityManager is associated with an active transaction, the persistence context remains managed until the transaction completes.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacejakarta.persistence.EntityManager
-
getEntityManagerFactory
public jakarta.persistence.EntityManagerFactory getEntityManagerFactory()
Return the entity manager factory for the entity manager.- Specified by:
getEntityManagerFactory
in interfacejakarta.persistence.EntityManager
- Returns:
- EntityManagerFactory instance
- Throws:
IllegalStateException
- if the entity manager has been closed.
-
getFetchPlan
public JakartaFetchPlan getFetchPlan()
Acessor for the current FetchPlan- Returns:
- The FetchPlan
-
contains
public boolean contains(Object entity)
Check if the instance belongs to the current persistence context.- Specified by:
contains
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The entity- Returns:
- Whether it is contained in the current context
- Throws:
IllegalArgumentException
- if not an entity
-
find
public Object find(Class entityClass, Object primaryKey)
Method to find an object from its primary key.- Specified by:
find
in interfacejakarta.persistence.EntityManager
- Parameters:
entityClass
- The entity classprimaryKey
- The PK value- Returns:
- the found entity instance or null if the entity does not exist
- Throws:
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
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
Find by primary key, using the specified properties. Search for an entity of the specified class and primary key. If the entity instance is contained in the persistence context it is returned from there. If a vendor-specific property or hint is not recognised, it is silently ignored.- Specified by:
find
in interfacejakarta.persistence.EntityManager
- Type Parameters:
T
- Type of the persistable- Parameters:
entityClass
- Class of the entity requiredprimaryKey
- The PK valueproperties
- standard and vendor-specific properties- Returns:
- the found entity instance or null if the entity does not exist
- Throws:
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 null
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lock)
- Specified by:
find
in interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lock, Map<String,Object> properties)
Method to return the persistent object of the specified entity type with the provided PK.- Specified by:
find
in interfacejakarta.persistence.EntityManager
- Type Parameters:
T
- Type of the persistable- Parameters:
entityClass
- Entity typeprimaryKey
- PK. Can be an instanceof the PK type, or the key when using single-fieldlock
- Any locking to applyproperties
- Any optional properties to control the operation- Returns:
- The object meeting this selection.
-
findByUnique
public <T> T findByUnique(Class<T> cls, String[] fieldNames, Object[] fieldValues)
Method to look up the instance of the given type with the given key.- Type Parameters:
T
- Type of the persistable- Parameters:
cls
- Class of the persistablefieldNames
- Name(s) of the field(s) making up the unique keyfieldValues
- Value(s) for the field(s) making up the unique key- Returns:
- The object meeting this selection.
-
getDelegate
public Object getDelegate()
Return the underlying provider object for the EntityManager, if available. The result of this method is implementation specific.- Specified by:
getDelegate
in interfacejakarta.persistence.EntityManager
- Returns:
- The ExecutionContext
-
unwrap
public <T> T unwrap(Class<T> cls)
Return an object of the specified type to allow access to the provider-specific API. If the provider's EntityManager implementation does not support the specified class, the PersistenceException is thrown.- Specified by:
unwrap
in interfacejakarta.persistence.EntityManager
- Type Parameters:
T
- Type of the object to unwrap- Parameters:
cls
- the class of the object to be returned. This is normally either the underlying EntityManager implementation class or an interface that it implements.- Returns:
- an instance of the specified class
- Throws:
jakarta.persistence.PersistenceException
- if the provider does not support the call.
-
getReference
public Object getReference(Class entityClass, Object primaryKey)
Get an instance, whose state may be lazily fetched. If the requested instance does not exist in the database, the EntityNotFoundException is thrown when the instance state is first accessed. The persistence provider runtime is permitted to throw the EntityNotFoundException when getReference is called. The application should not expect that the instance state will be available upon detachment, unless it was accessed by the application while the entity manager was open.- Specified by:
getReference
in interfacejakarta.persistence.EntityManager
- Parameters:
entityClass
- Class of the entityprimaryKey
- The PK- Returns:
- the found entity instance
- Throws:
IllegalArgumentException
- if the first argument does not denote an entity type or the second argument is not a valid type for that entities PKjakarta.persistence.EntityNotFoundException
- if the entity state cannot be accessed
-
lock
public void lock(Object entity, jakarta.persistence.LockModeType lockMode)
Set the lock mode for an entity object contained in the persistence context.- Specified by:
lock
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The EntitylockMode
- Lock mode- Throws:
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 transaction
-
lock
public void lock(Object entity, jakarta.persistence.LockModeType lock, Map<String,Object> properties)
Set the lock mode for an entity object contained in the persistence context.- Specified by:
lock
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The Entitylock
- Lock modeproperties
- Optional properties controlling the operation- Throws:
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 transaction
-
persist
public void persist(Object entity)
Make an instance managed and persistent.- Specified by:
persist
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The Entity- Throws:
jakarta.persistence.EntityExistsException
- if the entity already exists. (The EntityExistsException may be thrown when the persist operation is invoked, or the EntityExistsException/PersistenceException may be thrown at flush/commit time.)IllegalArgumentException
- if not an entityjakarta.persistence.TransactionRequiredException
- if invoked on a container-managed entity manager of type PersistenceContextType.TRANSACTION and there is no transaction.
-
persist
public void persist(Collection entities)
-
persist
public void persist(Object... entities)
-
merge
public Object merge(Object entity)
Merge the state of the given entity into the current persistence context.- Specified by:
merge
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The Entity- Returns:
- the instance that the state was merged to
- Throws:
IllegalArgumentException
- if instance is not an entity or is a removed entityjakarta.persistence.TransactionRequiredException
- if invoked on a container-managed entity manager of type PersistenceContextType.TRANSACTION and there is no transaction.
-
merge
public Collection merge(Collection entities)
-
detach
public void detach(Object entity)
Remove the given entity from the persistence context, causing a managed entity to become detached. Unflushed changes made to the entity if any (including removal of the entity) will not be synchronized to the database. Entities which previously referenced the detached entity will continue to reference it.- Specified by:
detach
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The entity- Throws:
IllegalArgumentException
- if the instance is not an entity
-
detach
public void detach(Collection entities)
-
detach
public void detach(Object... entities)
-
refresh
public void refresh(Object entity)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.- Specified by:
refresh
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The Entity- Throws:
IllegalArgumentException
- if not an entity or 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 database
-
refresh
public 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. If a vendor-specific property or hint is not recognised, it is silently ignored.- Specified by:
refresh
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The entityproperties
- standard and vendor-specific properties- Throws:
IllegalArgumentException
- 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 database
-
refresh
public void refresh(Object entity, jakarta.persistence.LockModeType lock)
- Specified by:
refresh
in interfacejakarta.persistence.EntityManager
-
refresh
public void refresh(Object entity, jakarta.persistence.LockModeType lock, Map<String,Object> properties)
- Specified by:
refresh
in interfacejakarta.persistence.EntityManager
-
remove
public void remove(Object entity)
Remove the entity instance.- Specified by:
remove
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The Entity- Throws:
IllegalArgumentException
- if not an entity or if a detached entityjakarta.persistence.TransactionRequiredException
- if invoked on a container-managed entity manager of type PersistenceContextType.TRANSACTION and there is no transaction.
-
remove
public void remove(Collection entities)
-
remove
public void remove(Object... entities)
-
flush
public void flush()
Synchronize the persistence context to the underlying database.- Specified by:
flush
in interfacejakarta.persistence.EntityManager
- Throws:
jakarta.persistence.TransactionRequiredException
- if there is no transactionjakarta.persistence.PersistenceException
- if the flush fails
-
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
Get the flush mode that applies to all objects contained in the persistence context.- Specified by:
getFlushMode
in interfacejakarta.persistence.EntityManager
- Returns:
- flushMode
-
setFlushMode
public void setFlushMode(jakarta.persistence.FlushModeType flushMode)
Set the flush mode that applies to all objects contained in the persistence context.- Specified by:
setFlushMode
in interfacejakarta.persistence.EntityManager
- Parameters:
flushMode
- Mode of flush
-
getLockMode
public jakarta.persistence.LockModeType getLockMode(Object entity)
Get the current lock mode for the entity instance.- Specified by:
getLockMode
in interfacejakarta.persistence.EntityManager
- Parameters:
entity
- The entity in question- Returns:
- lock mode
- Throws:
jakarta.persistence.TransactionRequiredException
- if there is no transactionIllegalArgumentException
- if the instance is not a managed entity and a transaction is active
-
getTransaction
public jakarta.persistence.EntityTransaction getTransaction()
Return the resource-level transaction object. The EntityTransaction instance may be used serially to begin and commit multiple transactions.- Specified by:
getTransaction
in interfacejakarta.persistence.EntityManager
- Returns:
- EntityTransaction instance
- Throws:
IllegalStateException
- if invoked on a JTA EntityManager.
-
joinTransaction
public void joinTransaction()
Indicate to the EntityManager that a JTA transaction is active so join to it. This method should be called on a JTA application managed EntityManager that was created outside the scope of the active transaction to associate it with the current JTA transaction.- Specified by:
joinTransaction
in interfacejakarta.persistence.EntityManager
- Throws:
jakarta.persistence.TransactionRequiredException
- if there is no transaction.
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
Return whether this EntityManager is joined to the current transaction. If we are using local transactions then returns whether the txn is active.- Specified by:
isJoinedToTransaction
in interfacejakarta.persistence.EntityManager
-
createQuery
public <T> jakarta.persistence.TypedQuery<T> createQuery(jakarta.persistence.criteria.CriteriaQuery<T> cq)
Method to return a query for the specified Criteria Query.- Specified by:
createQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
cq
- The Criteria query- Returns:
- The Jakarta Persistence query to use
-
createQuery
public jakarta.persistence.Query createQuery(jakarta.persistence.criteria.CriteriaUpdate crit)
- Specified by:
createQuery
in interfacejakarta.persistence.EntityManager
-
createQuery
public jakarta.persistence.Query createQuery(jakarta.persistence.criteria.CriteriaDelete crit)
- Specified by:
createQuery
in interfacejakarta.persistence.EntityManager
-
getCriteriaBuilder
public jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
Return an instance of QueryBuilder for the creation of Criteria API QueryDefinition objects.- Specified by:
getCriteriaBuilder
in interfacejakarta.persistence.EntityManager
- Returns:
- QueryBuilder instance
- Throws:
IllegalStateException
- if the entity manager has been closed.
-
createNamedQuery
public <T> jakarta.persistence.TypedQuery<T> createNamedQuery(String queryName, Class<T> resultClass)
Create an instance of Query for executing a named query (in JPQL or native).- Specified by:
createNamedQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
queryName
- the name of a query defined in metadataresultClass
- Result class for this query- Returns:
- the new query instance
- Throws:
IllegalArgumentException
- if a query has not been defined with the given name
-
createNamedQuery
public JakartaQuery createNamedQuery(String queryName)
Create an instance of Query for executing a named query (in JPQL or native).- Specified by:
createNamedQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
queryName
- the name of a query defined in metadata- Returns:
- the new query instance
- Throws:
IllegalArgumentException
- if a query has not been defined with the given name
-
createNativeQuery
public jakarta.persistence.Query createNativeQuery(String queryString)
Create an instance of Query for executing a native query statement.- Specified by:
createNativeQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
queryString
- a native query string- Returns:
- the new query instance
-
createNativeQuery
public jakarta.persistence.Query createNativeQuery(String queryString, Class resultClass)
Create an instance of Query for executing a "native" query. The native query language could be SQL (for RDBMS), or CQL (for Cassandra), or some other depending on the store.- Specified by:
createNativeQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
queryString
- a native query stringresultClass
- the class of the resulting instance(s)- Returns:
- the new query instance
-
createNativeQuery
public jakarta.persistence.Query createNativeQuery(String queryString, String resultSetMapping)
Create an instance of Query for executing a native query. The native query language could be SQL (for RDBMS), or CQL (for Cassandra), or some other depending on the store.- Specified by:
createNativeQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
queryString
- a native query stringresultSetMapping
- the name of the result set mapping- Returns:
- the new query instance
-
createNamedStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createNamedStoredProcedureQuery(String procName)
Create an instance of Query for executing a stored procedure.- Specified by:
createNamedStoredProcedureQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
procName
- the name of the stored procedure defined in metadata- Returns:
- the new query instance
- Throws:
IllegalArgumentException
- if a stored procedure has not been defined with the given name
-
createStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procName)
Create an instance of Query for executing a stored procedure.- Specified by:
createStoredProcedureQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
procName
- Name of stored procedure defined in metadata- Returns:
- the new stored procedure query instance
-
createStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses)
Create an instance of 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.- Specified by:
createStoredProcedureQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
procedureName
- name of the stored procedure in the databaseresultClasses
- classes to which the result sets produced by the stored procedure are to be mapped- Returns:
- the new stored procedure query instance
- Throws:
IllegalArgumentException
- if a stored procedure of the given name does not exist or the query execution will fail
-
createStoredProcedureQuery
public jakarta.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Create an instance of StoredProcedureQuery for executing a stored procedure in the database. Parameters must be registered before the stored procedure can be executed. The resultSetMappings argument must be specified in the order in which the result sets will be returned by the stored procedure invocation.- Specified by:
createStoredProcedureQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
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 procedure- Returns:
- the new stored procedure query instance
- Throws:
IllegalArgumentException
- if a stored procedure or result set mapping of the given name does not exist or the query execution will fail
-
createQuery
public <T> jakarta.persistence.TypedQuery<T> createQuery(String queryString, Class<T> resultClass)
- Specified by:
createQuery
in interfacejakarta.persistence.EntityManager
-
createQuery
public JakartaQuery createQuery(String queryString)
Create an instance of Query for executing a JPQL statement.- Specified by:
createQuery
in interfacejakarta.persistence.EntityManager
- Parameters:
queryString
- a Java Persistence query string- Returns:
- the new query instance
- Throws:
IllegalArgumentException
- if query string is not valid
-
setProperty
public void setProperty(String propertyName, Object value)
Set an entity manager property. If a vendor-specific property is not recognized, it is silently ignored.- Specified by:
setProperty
in interfacejakarta.persistence.EntityManager
- Parameters:
propertyName
- Name of the propertyvalue
- The value- Throws:
IllegalArgumentException
- if the second argument is not valid for the implementation
-
getProperties
public Map<String,Object> getProperties()
Get the properties and associated values that are in effect for the entity manager. Changing the contents of the map does not change the configuration in effect.- Specified by:
getProperties
in interfacejakarta.persistence.EntityManager
-
getSupportedProperties
public Set<String> getSupportedProperties()
Get the names of the properties that are supported for use with the entity manager. These correspond to properties and hints that may be passed to the methods of the EntityManager interface that take a properties argument or used with the PersistenceContext annotation. These properties include all standard entity manager hints and properties as well as vendor-specific one supported by the provider. These properties may or may not currently be in effect.- Returns:
- property names Names of the properties accepted
-
getMetamodel
public jakarta.persistence.metamodel.Metamodel getMetamodel()
Return an instance of Metamodel interface for access to the metamodel of the persistence unit.- Specified by:
getMetamodel
in interfacejakarta.persistence.EntityManager
- Returns:
- Metamodel instance
- Throws:
IllegalStateException
- if the entity manager has been closed.
-
isTransactionActive
public boolean isTransactionActive()
-
getLockModeForJakartaLockModeType
public static org.datanucleus.state.LockMode getLockModeForJakartaLockModeType(jakarta.persistence.LockModeType lock)
Convenience method to convert from the Jakarta Persistence LockModeType to the internal lock mode.- Parameters:
lock
- Jakarta Persistence LockModeType- Returns:
- The internal lock mode
-
getJakartaLockModeTypeForLockMode
public static jakarta.persistence.LockModeType getJakartaLockModeTypeForLockMode(org.datanucleus.state.LockMode lockMode)
Convenience method to convert from LockManager lock type to Jakarta Persistence LockModeType- Parameters:
lockMode
- Lock mode- Returns:
- Jakarta Persistence LockModeType
-
createEntityGraph
public <T> jakarta.persistence.EntityGraph<T> createEntityGraph(Class<T> rootType)
- Specified by:
createEntityGraph
in interfacejakarta.persistence.EntityManager
-
createEntityGraph
public jakarta.persistence.EntityGraph<?> createEntityGraph(String graphName)
- Specified by:
createEntityGraph
in interfacejakarta.persistence.EntityManager
-
getEntityGraph
public jakarta.persistence.EntityGraph<?> getEntityGraph(String graphName)
- Specified by:
getEntityGraph
in interfacejakarta.persistence.EntityManager
-
-