public class EntityManagerImpl extends EntityManagerImpl implements EntityManager
Purpose: Contains the implementation of the EntityManager.
Description: This class provides the implementation for the combined TopLink and EJB3.0 EntityManager class.
Responsibilities:It is responcible for tracking transaction state and the objects within that transaction.
EntityManager
,
EntityManager
extended, extendedPersistenceContext, factory, isOpen, propagatePersistenceContext, serverSession, transaction
Constructor and Description |
---|
EntityManagerImpl(EntityManagerFactoryImpl factory,
java.util.Map properties,
boolean propagePersistenceContext,
boolean extended)
Constructor called from the EntityManagerFactory to create an EntityManager
|
EntityManagerImpl(ServerSession serverSession,
boolean propagatePersistenceContext,
boolean extended)
Constructor called from the EntityManagerFactory to create an EntityManager
|
EntityManagerImpl(ServerSession serverSession,
java.util.Map properties,
boolean propagePersistenceContext,
boolean extended)
Constructor called from the EntityManagerFactory to create an EntityManager
|
EntityManagerImpl(java.lang.String sessionName,
boolean propagatePersistenceContext,
boolean extended)
Constructor returns an EntityManager assigned to the a particular ServerSession.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the persistence context, causing all managed
entities to become detached.
|
void |
close()
Closes this EntityManager.
|
boolean |
contains(java.lang.Object arg0)
Check if the instance belongs to the current persistence
context.
|
javax.persistence.Query |
createNamedQuery(java.lang.String name)
Create an instance of Query for executing a
named query (in EJBQL or native SQL).
|
<T> javax.persistence.TypedQuery<T> |
createNamedQuery(java.lang.String arg0,
java.lang.Class<T> arg1) |
javax.persistence.Query |
createNativeQuery(java.lang.String sqlString)
Create an instance of Query for executing
a native SQL query.
|
javax.persistence.Query |
createNativeQuery(java.lang.String sqlString,
java.lang.Class resultType)
This method is used to create a query using SQL.
|
javax.persistence.Query |
createNativeQuery(java.lang.String sqlString,
java.lang.String resultSetMapping)
Create an instance of Query for executing
a native SQL query.
|
<T> javax.persistence.TypedQuery<T> |
createQuery(javax.persistence.criteria.CriteriaQuery<T> arg0) |
javax.persistence.Query |
createQuery(Expression expression,
java.lang.Class resultType)
This method is used to create a query using a Toplink Expression and the return type.
|
javax.persistence.Query |
createQuery(java.lang.String ejbqlString)
Create an instance of Query for executing an
EJBQL query.
|
<T> javax.persistence.TypedQuery<T> |
createQuery(java.lang.String arg0,
java.lang.Class<T> arg1) |
void |
detach(java.lang.Object arg0) |
<T> T |
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
Find by primary key.
|
<T> T |
find(java.lang.Class<T> arg0,
java.lang.Object arg1,
javax.persistence.LockModeType arg2) |
<T> T |
find(java.lang.Class<T> arg0,
java.lang.Object arg1,
javax.persistence.LockModeType arg2,
java.util.Map<java.lang.String,java.lang.Object> arg3) |
<T> T |
find(java.lang.Class<T> arg0,
java.lang.Object arg1,
java.util.Map<java.lang.String,java.lang.Object> arg2) |
void |
flush()
Synchronize the persistence context with the
underlying database.
|
javax.persistence.criteria.CriteriaBuilder |
getCriteriaBuilder() |
java.lang.Object |
getDelegate()
Return the underlying provider object for the EntityManager,
if available.
|
javax.persistence.EntityManagerFactory |
getEntityManagerFactory() |
javax.persistence.FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained
in the persistence context.
|
javax.persistence.LockModeType |
getLockMode(java.lang.Object arg0) |
javax.persistence.metamodel.Metamodel |
getMetamodel() |
java.util.Map<java.lang.String,java.lang.Object> |
getProperties() |
<T> T |
getReference(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
Get an instance, whose state may be lazily fetched.
|
javax.persistence.EntityTransaction |
getTransaction()
Returns the resource-level transaction object.
|
boolean |
isFlushModeAUTO()
Internal method.
|
boolean |
isOpen()
Indicates whether or not this entity manager is open.
|
void |
joinTransaction()
Indicate to the EntityManager that a JTA transaction is
active.
|
void |
lock(java.lang.Object arg0,
javax.persistence.LockModeType arg1)
Set the lock mode for an entity object contained in the persistence context.
|
void |
lock(java.lang.Object arg0,
javax.persistence.LockModeType arg1,
java.util.Map<java.lang.String,java.lang.Object> arg2) |
<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.
|
void |
persist(java.lang.Object arg0)
If in a transaction this method will check for existence and register the object if
it is new.
|
void |
refresh(java.lang.Object arg0)
Refresh the state of the instance from the
database.
|
void |
refresh(java.lang.Object arg0,
javax.persistence.LockModeType arg1) |
void |
refresh(java.lang.Object arg0,
javax.persistence.LockModeType arg1,
java.util.Map<java.lang.String,java.lang.Object> arg2) |
void |
refresh(java.lang.Object arg0,
java.util.Map<java.lang.String,java.lang.Object> arg1) |
void |
remove(java.lang.Object arg0)
Remove the instance.
|
protected void |
setEntityTransactionWrapper() |
void |
setFlushMode(javax.persistence.FlushModeType flushMode)
Set the flush mode that applies to all objects contained
in the persistence context.
|
protected void |
setJTATransactionWrapper() |
void |
setProperty(java.lang.String arg0,
java.lang.Object arg1) |
<T> T |
unwrap(java.lang.Class<T> arg0) |
checkForTransaction, contains, createNativeQueryInternal, createQueryInternal, detectTransactionWrapper, find, findInternal, findInternal, getActivePersistenceContext, getActiveSession, getServerSession, getSession, getTransactionalUnitOfWork_new, getUnitOfWork, isExtended, mergeInternal, removeExtendedPersistenceContext, setRollbackOnly, shouldFlushBeforeQuery, shouldPropagatePersistenceContext, verifyOpen
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getActiveSession, getServerSession, getSession, getUnitOfWork
public EntityManagerImpl(java.lang.String sessionName, boolean propagatePersistenceContext, boolean extended)
sessionName
- the ServerSession name that should be used.
This constructor can potentially throw TopLink exceptions regarding the existence, or
errors with the specified session.public EntityManagerImpl(ServerSession serverSession, boolean propagatePersistenceContext, boolean extended)
serverSession
- the serverSession assigned to this deployment.public EntityManagerImpl(ServerSession serverSession, java.util.Map properties, boolean propagePersistenceContext, boolean extended)
serverSession
- the serverSession 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(EntityManagerFactoryImpl factory, java.util.Map properties, boolean propagePersistenceContext, boolean extended)
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 implementedpublic void clear()
EntityManagerImpl
clear
in interface javax.persistence.EntityManager
clear
in class EntityManagerImpl
public void close()
EntityManagerImpl
Closes this EntityManager.
After invoking this method, all methods on the instance will throw an
IllegalStateException
except for EntityManagerImpl.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 javax.persistence.EntityManager
close
in class EntityManagerImpl
public boolean contains(java.lang.Object arg0)
EntityManagerImpl
contains
in interface javax.persistence.EntityManager
contains
in class EntityManagerImpl
public <T> javax.persistence.TypedQuery<T> createNamedQuery(java.lang.String arg0, java.lang.Class<T> arg1)
createNamedQuery
in interface javax.persistence.EntityManager
public <T> javax.persistence.TypedQuery<T> createQuery(javax.persistence.criteria.CriteriaQuery<T> arg0)
createQuery
in interface javax.persistence.EntityManager
public <T> javax.persistence.TypedQuery<T> createQuery(java.lang.String arg0, java.lang.Class<T> arg1)
createQuery
in interface javax.persistence.EntityManager
public void detach(java.lang.Object arg0)
detach
in interface javax.persistence.EntityManager
public <T> T find(java.lang.Class<T> arg0, java.lang.Object arg1, java.util.Map<java.lang.String,java.lang.Object> arg2)
find
in interface javax.persistence.EntityManager
public <T> T find(java.lang.Class<T> arg0, java.lang.Object arg1, javax.persistence.LockModeType arg2)
find
in interface javax.persistence.EntityManager
public <T> T find(java.lang.Class<T> arg0, java.lang.Object arg1, javax.persistence.LockModeType arg2, java.util.Map<java.lang.String,java.lang.Object> arg3)
find
in interface javax.persistence.EntityManager
public void flush()
EntityManagerImpl
flush
in interface javax.persistence.EntityManager
flush
in class EntityManagerImpl
public javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
getCriteriaBuilder
in interface javax.persistence.EntityManager
public java.lang.Object getDelegate()
EntityManagerImpl
getDelegate
in interface javax.persistence.EntityManager
getDelegate
in class EntityManagerImpl
public javax.persistence.EntityManagerFactory getEntityManagerFactory()
getEntityManagerFactory
in interface javax.persistence.EntityManager
public javax.persistence.LockModeType getLockMode(java.lang.Object arg0)
getLockMode
in interface javax.persistence.EntityManager
public javax.persistence.metamodel.Metamodel getMetamodel()
getMetamodel
in interface javax.persistence.EntityManager
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
getProperties
in interface javax.persistence.EntityManager
public boolean isOpen()
EntityManagerImpl
true
until
a call to EntityManagerImpl.close()
is made.isOpen
in interface javax.persistence.EntityManager
isOpen
in class EntityManagerImpl
public void joinTransaction()
EntityManagerImpl
joinTransaction
in interface javax.persistence.EntityManager
joinTransaction
in class EntityManagerImpl
public void lock(java.lang.Object arg0, javax.persistence.LockModeType arg1)
EntityManagerImpl
lock
in interface javax.persistence.EntityManager
lock
in class EntityManagerImpl
public void lock(java.lang.Object arg0, javax.persistence.LockModeType arg1, java.util.Map<java.lang.String,java.lang.Object> arg2)
lock
in interface javax.persistence.EntityManager
public void persist(java.lang.Object arg0)
EntityManagerImpl
persist
in interface javax.persistence.EntityManager
persist
in class EntityManagerImpl
public void refresh(java.lang.Object arg0)
EntityManagerImpl
refresh
in interface javax.persistence.EntityManager
refresh
in class EntityManagerImpl
public void refresh(java.lang.Object arg0, java.util.Map<java.lang.String,java.lang.Object> arg1)
refresh
in interface javax.persistence.EntityManager
public void refresh(java.lang.Object arg0, javax.persistence.LockModeType arg1)
refresh
in interface javax.persistence.EntityManager
public void refresh(java.lang.Object arg0, javax.persistence.LockModeType arg1, java.util.Map<java.lang.String,java.lang.Object> arg2)
refresh
in interface javax.persistence.EntityManager
public void remove(java.lang.Object arg0)
EntityManagerImpl
remove
in interface javax.persistence.EntityManager
remove
in class EntityManagerImpl
public void setProperty(java.lang.String arg0, java.lang.Object arg1)
setProperty
in interface javax.persistence.EntityManager
public <T> T unwrap(java.lang.Class<T> arg0)
unwrap
in interface javax.persistence.EntityManager
public <T> T merge(T entity)
merge
in interface javax.persistence.EntityManager
entity
- public <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
find
in interface javax.persistence.EntityManager
entityClass
- primaryKey
- java.lang.IllegalArgumentException
- if the first argument does
not denote an entity type or the second argument is not a valid type for that
entity's primary keypublic <T> T getReference(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
getReference
in interface javax.persistence.EntityManager
entityClass
- primaryKey
- java.lang.IllegalArgumentException
- if the first argument does
not denote an entity type or the second
argument is not a valid type for that
entity's primary keyjavax.persistence.EntityNotFoundException
- if the entity state
cannot be accessedpublic javax.persistence.Query createQuery(java.lang.String ejbqlString)
createQuery
in interface javax.persistence.EntityManager
ejbqlString
- an EJBQL query stringpublic javax.persistence.Query createNamedQuery(java.lang.String name)
createNamedQuery
in interface javax.persistence.EntityManager
name
- the name of a query defined in metadatapublic javax.persistence.Query createNativeQuery(java.lang.String sqlString)
createNativeQuery
in interface javax.persistence.EntityManager
sqlString
- a native SQL query stringpublic javax.persistence.Query createNativeQuery(java.lang.String sqlString, java.lang.Class resultType)
createNativeQuery
in interface javax.persistence.EntityManager
public javax.persistence.Query createNativeQuery(java.lang.String sqlString, java.lang.String resultSetMapping)
createNativeQuery
in interface javax.persistence.EntityManager
sqlString
- a native SQL query stringresultSetMapping
- the name of the result set mappingjava.lang.IllegalArgumentException
- if query string is not validpublic javax.persistence.FlushModeType getFlushMode()
getFlushMode
in interface javax.persistence.EntityManager
public void setFlushMode(javax.persistence.FlushModeType flushMode)
setFlushMode
in interface javax.persistence.EntityManager
flushMode
- public javax.persistence.Query createQuery(Expression expression, java.lang.Class resultType)
public javax.persistence.EntityTransaction getTransaction()
getTransaction
in interface javax.persistence.EntityManager
java.lang.IllegalStateException
- if invoked on a JTA
EntityManager.public boolean isFlushModeAUTO()
isFlushModeAUTO
in class EntityManagerImpl
protected void setJTATransactionWrapper()
setJTATransactionWrapper
in class EntityManagerImpl
protected void setEntityTransactionWrapper()
setEntityTransactionWrapper
in class EntityManagerImpl