|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.jpa.EntityManagerImpl
public class EntityManagerImpl
EntityManager implementation for JPA.
| Field Summary | |
|---|---|
protected javax.persistence.EntityManagerFactory |
emf
Parent EntityManagerFactory. |
protected JPAFetchPlan |
fetchPlan
Fetch Plan (extension). |
protected javax.persistence.FlushModeType |
flushMode
The Flush Mode. |
protected static org.datanucleus.util.Localiser |
LOCALISER
Localisation utility for output messages |
protected org.datanucleus.ObjectManager |
om
The underlying ObjectManager managing the persistence. |
protected javax.persistence.PersistenceContextType |
persistenceContextType
Type of Persistence Context |
protected javax.jdo.PersistenceManager |
pm
Underlying PersistenceManager that provides the persistence capability. |
protected javax.persistence.EntityTransaction |
tx
Current Transaction (when using ResourceLocal). |
| Constructor Summary | |
|---|---|
EntityManagerImpl(javax.persistence.EntityManagerFactory emf,
javax.jdo.PersistenceManagerFactory pmf,
javax.persistence.PersistenceContextType contextType)
Constructor. |
|
| Method Summary | ||
|---|---|---|
void |
clear()
Clear the persistence context, causing all managed entities to become detached. |
|
void |
close()
Close an application-managed EntityManager. |
|
boolean |
contains(java.lang.Object entity)
Check if the instance belongs to the current persistence context. |
|
JPAQuery |
createNamedQuery(java.lang.String queryName)
Create an instance of Query for executing a named query (in JPQL or SQL). |
|
|
createNamedQuery(java.lang.String queryName,
java.lang.Class<T> resultClass)
Create an instance of Query for executing a named query (in JPQL or SQL). |
|
javax.persistence.Query |
createNativeQuery(java.lang.String sqlString)
Create an instance of Query for executing an SQL statement. |
|
javax.persistence.Query |
createNativeQuery(java.lang.String sqlString,
java.lang.Class resultClass)
Create an instance of Query for executing an SQL query. |
|
javax.persistence.Query |
createNativeQuery(java.lang.String sqlString,
java.lang.String resultSetMapping)
Create an instance of Query for executing an SQL query. |
|
|
createQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Method to return a query for the specified Criteria Query. |
|
JPAQuery |
createQuery(java.lang.String queryString)
Create an instance of Query for executing a JPQL statement. |
|
|
createQuery(java.lang.String queryString,
java.lang.Class<T> resultClass)
|
|
void |
detach(java.lang.Object entity)
Remove the given entity from the persistence context, causing a managed entity to become detached. |
|
|
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
javax.persistence.LockModeType lock)
|
|
|
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
javax.persistence.LockModeType lock,
java.util.Map<java.lang.String,java.lang.Object> properties)
Method to return the persistent object of the specified entity type with the provided PK. |
|
|
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.Class entityClass,
java.lang.Object primaryKey)
Method to find an object from its primary key. |
|
void |
flush()
Synchronize the persistence context to the underlying database. |
|
javax.persistence.criteria.CriteriaBuilder |
getCriteriaBuilder()
Return an instance of QueryBuilder for the creation of Criteria API QueryDefinition objects. |
|
java.lang.Object |
getDelegate()
Return the underlying provider object for the EntityManager, if available. |
|
javax.persistence.EntityManagerFactory |
getEntityManagerFactory()
Return the entity manager factory for the entity manager. |
|
JPAFetchPlan |
getFetchPlan()
Acessor for the current FetchPlan |
|
javax.persistence.FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained in the persistence context. |
|
static javax.persistence.LockModeType |
getJPALockModeTypeForLockType(short lockType)
Convenience method to convert from LockManager lock type to JPA LockModeType |
|
javax.persistence.LockModeType |
getLockMode(java.lang.Object entity)
Get the current lock mode for the entity instance. |
|
static short |
getLockTypeForJPALockModeType(javax.persistence.LockModeType lock)
Convenience method to convert from the JPA LockModeType to the type expected by LockManager |
|
javax.persistence.metamodel.Metamodel |
getMetamodel()
Return an instance of Metamodel interface for access to the metamodel of the persistence unit. |
|
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Get the properties and associated values that are in effect for the entity manager. |
|
java.lang.Object |
getReference(java.lang.Class entityClass,
java.lang.Object primaryKey)
Get an instance, whose state may be lazily fetched. |
|
java.util.Set<java.lang.String> |
getSupportedProperties()
Get the names of the properties that are supported for use with the entity manager. |
|
javax.persistence.EntityTransaction |
getTransaction()
Return the resource-level transaction object. |
|
boolean |
isOpen()
Determine whether the EntityManager is open. |
|
void |
joinTransaction()
Indicate to the EntityManager that a JTA transaction is active. |
|
void |
lock(java.lang.Object entity,
javax.persistence.LockModeType lockMode)
Set the lock mode for an entity object contained in the persistence context. |
|
void |
lock(java.lang.Object entity,
javax.persistence.LockModeType lock,
java.util.Map<java.lang.String,java.lang.Object> properties)
Set the lock mode for an entity object contained in the persistence context. |
|
java.lang.Object |
merge(java.lang.Object entity)
Merge the state of the given entity into the current persistence context. |
|
void |
persist(java.lang.Object entity)
Make an instance managed and persistent. |
|
void |
refresh(java.lang.Object entity)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any. |
|
void |
refresh(java.lang.Object entity,
javax.persistence.LockModeType lock)
|
|
void |
refresh(java.lang.Object entity,
javax.persistence.LockModeType lock,
java.util.Map<java.lang.String,java.lang.Object> properties)
|
|
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 entity instance. |
|
void |
setFlushMode(javax.persistence.FlushModeType flushMode)
Set the flush mode that applies to all objects contained in the persistence context. |
|
void |
setProperty(java.lang.String propertyName,
java.lang.Object value)
Set an entity manager property. |
|
|
unwrap(java.lang.Class<T> cls)
Return an object of the specified type to allow access to the provider-specific API. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.datanucleus.util.Localiser LOCALISER
protected javax.jdo.PersistenceManager pm
protected org.datanucleus.ObjectManager om
protected javax.persistence.EntityManagerFactory emf
protected javax.persistence.EntityTransaction tx
protected javax.persistence.FlushModeType flushMode
protected javax.persistence.PersistenceContextType persistenceContextType
protected JPAFetchPlan fetchPlan
| Constructor Detail |
|---|
public EntityManagerImpl(javax.persistence.EntityManagerFactory emf,
javax.jdo.PersistenceManagerFactory pmf,
javax.persistence.PersistenceContextType contextType)
emf - The parent EntityManagerFactorypmf - The underlying PersistenceManagerFactory that handles persistencecontextType - The Persistence Context type| Method Detail |
|---|
public void clear()
clear in interface javax.persistence.EntityManagerpublic boolean isOpen()
isOpen in interface javax.persistence.EntityManagerpublic void close()
close in interface javax.persistence.EntityManagerjava.lang.IllegalStateException - if the EntityManager is container-managed.public javax.persistence.EntityManagerFactory getEntityManagerFactory()
getEntityManagerFactory in interface javax.persistence.EntityManagerjava.lang.IllegalStateException - if the entity manager has
been closed.public JPAFetchPlan getFetchPlan()
public boolean contains(java.lang.Object entity)
contains in interface javax.persistence.EntityManagerentity -
java.lang.IllegalArgumentException - if not an entity
public java.lang.Object find(java.lang.Class entityClass,
java.lang.Object primaryKey)
find in interface javax.persistence.EntityManagerentityClass - The entity classprimaryKey - The PK value
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)
find in interface javax.persistence.EntityManagerentityClass - Class of the entity requiredprimaryKey - The PK valueproperties - standard and vendor-specific properties
java.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 null
public <T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
javax.persistence.LockModeType lock)
find in interface javax.persistence.EntityManager
public <T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
javax.persistence.LockModeType lock,
java.util.Map<java.lang.String,java.lang.Object> properties)
find in interface javax.persistence.EntityManagerentityClass - 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 operationpublic java.lang.Object getDelegate()
getDelegate in interface javax.persistence.EntityManagerpublic <T> T unwrap(java.lang.Class<T> cls)
unwrap in interface javax.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.
javax.persistence.PersistenceException - if the provider does not support the call.
public java.lang.Object getReference(java.lang.Class entityClass,
java.lang.Object primaryKey)
getReference in interface javax.persistence.EntityManagerentityClass - Class of the entityprimaryKey - The PK
java.lang.IllegalArgumentException - if the first argument does not denote an entity type or the second argument is not
a valid type for that entities PK
javax.persistence.EntityNotFoundException - if the entity state cannot be accessed
public void lock(java.lang.Object entity,
javax.persistence.LockModeType lockMode)
lock in interface javax.persistence.EntityManagerentity - The EntitylockMode - Lock mode
javax.persistence.PersistenceException - if an unsupported lock call is made
java.lang.IllegalArgumentException - if the instance is not an entity or is a detached entity
javax.persistence.TransactionRequiredException - if there is no transaction
public void lock(java.lang.Object entity,
javax.persistence.LockModeType lock,
java.util.Map<java.lang.String,java.lang.Object> properties)
lock in interface javax.persistence.EntityManagerentity - The Entitylock - Lock modeproperties - Optional properties controlling the operation
javax.persistence.PersistenceException - if an unsupported lock call is made
java.lang.IllegalArgumentException - if the instance is not an entity or is a detached entity
javax.persistence.TransactionRequiredException - if there is no transactionpublic void persist(java.lang.Object entity)
persist in interface javax.persistence.EntityManagerentity - The Entity
javax.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.)
java.lang.IllegalArgumentException - if not an entity
javax.persistence.TransactionRequiredException - if invoked on a container-managed entity manager
of type PersistenceContextType.TRANSACTION and there is no transaction.public java.lang.Object merge(java.lang.Object entity)
merge in interface javax.persistence.EntityManagerentity - The Entity
java.lang.IllegalArgumentException - if instance is not an entity or is a removed entity
javax.persistence.TransactionRequiredException - if invoked on a container-managed entity manager
of type PersistenceContextType.TRANSACTION and there is no transaction.public void detach(java.lang.Object entity)
detach in interface javax.persistence.EntityManagerentity -
java.lang.IllegalArgumentException - if the instance is not an entitypublic void refresh(java.lang.Object entity)
refresh in interface javax.persistence.EntityManagerentity - The Entity
java.lang.IllegalArgumentException - if not an entity or entity is not managed
javax.persistence.TransactionRequiredException - if invoked on a container-managed entity manager
of type PersistenceContextType.TRANSACTION and there is no transaction.
javax.persistence.EntityNotFoundException - if the entity no longer exists in the database
public void refresh(java.lang.Object entity,
java.util.Map<java.lang.String,java.lang.Object> properties)
refresh in interface javax.persistence.EntityManagerentity - properties - standard and vendor-specific properties
java.lang.IllegalArgumentException - if the instance is not
an entity or the entity is not managed
javax.persistence.TransactionRequiredException - if invoked on a container-managed entity manager
of type PersistenceContextType.TRANSACTION and there is no transaction.
javax.persistence.EntityNotFoundException - if the entity no longer exists in the database
public void refresh(java.lang.Object entity,
javax.persistence.LockModeType lock)
refresh in interface javax.persistence.EntityManager
public void refresh(java.lang.Object entity,
javax.persistence.LockModeType lock,
java.util.Map<java.lang.String,java.lang.Object> properties)
refresh in interface javax.persistence.EntityManagerpublic void remove(java.lang.Object entity)
remove in interface javax.persistence.EntityManagerentity - The Entity
java.lang.IllegalArgumentException - if not an entity or if a detached entity
javax.persistence.TransactionRequiredException - if invoked on a container-managed entity manager
of type PersistenceContextType.TRANSACTION and there is no transaction.public void flush()
flush in interface javax.persistence.EntityManagerjavax.persistence.TransactionRequiredException - if there is no transaction
javax.persistence.PersistenceException - if the flush failspublic javax.persistence.FlushModeType getFlushMode()
getFlushMode in interface javax.persistence.EntityManagerpublic void setFlushMode(javax.persistence.FlushModeType flushMode)
setFlushMode in interface javax.persistence.EntityManagerflushMode - Mode of flushpublic javax.persistence.LockModeType getLockMode(java.lang.Object entity)
getLockMode in interface javax.persistence.EntityManagerentity - The entity in question
javax.persistence.TransactionRequiredException - if there is no transaction
java.lang.IllegalArgumentException - if the instance is not a managed entity and a transaction is activepublic javax.persistence.EntityTransaction getTransaction()
getTransaction in interface javax.persistence.EntityManagerjava.lang.IllegalStateException - if invoked on a JTA EntityManager.public void joinTransaction()
joinTransaction in interface javax.persistence.EntityManagerjavax.persistence.TransactionRequiredException - if there is no transaction.public <T> javax.persistence.TypedQuery<T> createQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
createQuery in interface javax.persistence.EntityManagercriteriaQuery - The Criteria query
public javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
getCriteriaBuilder in interface javax.persistence.EntityManagerjava.lang.IllegalStateException - if the entity manager has been closed.
public <T> javax.persistence.TypedQuery<T> createNamedQuery(java.lang.String queryName,
java.lang.Class<T> resultClass)
createNamedQuery in interface javax.persistence.EntityManagerqueryName - the name of a query defined in metadata
java.lang.IllegalArgumentException - if a query has not been defined with the given namepublic JPAQuery createNamedQuery(java.lang.String queryName)
createNamedQuery in interface javax.persistence.EntityManagerqueryName - the name of a query defined in metadata
java.lang.IllegalArgumentException - if a query has not been defined with the given namepublic javax.persistence.Query createNativeQuery(java.lang.String sqlString)
createNativeQuery in interface javax.persistence.EntityManagersqlString - a native SQL query string
public javax.persistence.Query createNativeQuery(java.lang.String sqlString,
java.lang.Class resultClass)
createNativeQuery in interface javax.persistence.EntityManagersqlString - a native SQL query stringresultClass - the class of the resulting instance(s)
public javax.persistence.Query createNativeQuery(java.lang.String sqlString,
java.lang.String resultSetMapping)
createNativeQuery in interface javax.persistence.EntityManagersqlString - a native SQL query stringresultSetMapping - the name of the result set mapping
public <T> javax.persistence.TypedQuery<T> createQuery(java.lang.String queryString,
java.lang.Class<T> resultClass)
createQuery in interface javax.persistence.EntityManagerpublic JPAQuery createQuery(java.lang.String queryString)
createQuery in interface javax.persistence.EntityManagerqueryString - a Java Persistence query string
java.lang.IllegalArgumentException - if query string is not valid
public void setProperty(java.lang.String propertyName,
java.lang.Object value)
setProperty in interface javax.persistence.EntityManagerpropertyName - Name of the propertyvalue - The value
java.lang.IllegalArgumentException - if the second argument is not valid for the implementationpublic java.util.Map<java.lang.String,java.lang.Object> getProperties()
getProperties in interface javax.persistence.EntityManagerpublic java.util.Set<java.lang.String> getSupportedProperties()
public javax.persistence.metamodel.Metamodel getMetamodel()
getMetamodel in interface javax.persistence.EntityManagerjava.lang.IllegalStateException - if the entity manager has been closed.public static short getLockTypeForJPALockModeType(javax.persistence.LockModeType lock)
lock - JPA LockModeType
public static javax.persistence.LockModeType getJPALockModeTypeForLockType(short lockType)
lockType - Lock type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||