|
EclipseLink 2.0.0_ 2.0.0.v20090626-r4569 API Reference | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface EntityManager
Interface used to interact with the persistence context.
| 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 is a managed entity instance belonging to the current persistence context. |
|
Query |
createNamedQuery(java.lang.String name)
Create an instance of Query for executing a named query (in the Java Persistence query language or in native SQL). |
|
|
createNamedQuery(java.lang.String name,
java.lang.Class<T> resultClass)
Create an instance of TypedQuery for executing a named query (in the Java Persistence query language or in native SQL). |
|
Query |
createNativeQuery(java.lang.String sqlString)
Create an instance of Query for executing a native SQL statement, e.g., for update or delete. |
|
Query |
createNativeQuery(java.lang.String sqlString,
java.lang.Class resultClass)
Create an instance of Query for executing a native SQL query. |
|
Query |
createNativeQuery(java.lang.String sqlString,
java.lang.String resultSetMapping)
Create an instance of Query for executing a native SQL query. |
|
|
createQuery(CriteriaQuery<T> criteriaQuery)
Create an instance of TypedQuery for executing a criteria query. |
|
Query |
createQuery(java.lang.String qlString)
Create an instance of Query for executing a Java Persistence query language statement. |
|
|
createQuery(java.lang.String qlString,
java.lang.Class<T> resultClass)
Create an instance of TypedQuery for executing a Java Persistence query language statement. |
|
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)
Find by primary key. |
|
|
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode)
Find by primary key and lock. |
|
|
find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Find by primary key and lock, using the specified properties. |
|
|
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. |
|
void |
flush()
Synchronize the persistence context to the underlying database. |
|
java.lang.Object |
getDelegate()
Return the underlying provider object for the EntityManager, if available. |
|
EntityManagerFactory |
getEntityManagerFactory()
Return the entity manager factory for the entity manager. |
|
FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained in the persistence context. |
|
LockModeType |
getLockMode(java.lang.Object entity)
Get the current lock mode for the entity instance. |
|
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. |
|
QueryBuilder |
getQueryBuilder()
Return an instance of QueryBuilder for the creation of CriteriaQuery objects. |
|
|
getReference(java.lang.Class<T> 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. |
|
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,
LockModeType lockMode)
Lock an entity instance that is contained in the persistence context with the specified lock mode type. |
|
void |
lock(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
Lock an entity instance that is contained in the persistence context with the specified lock mode type and with specified properties. |
|
|
merge(T 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,
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(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.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 and with specified 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(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. |
|
| Method Detail |
|---|
void persist(java.lang.Object entity)
entity -
EntityExistsException - if the entity already exists. (If the entity already exists,
the EntityExistsException may be thrown when the persist
operation is invoked, or the EntityExistsException or another
PersistenceException may be thrown at flush or commit time.)
java.lang.IllegalArgumentException - if the instance is not an entity
TransactionRequiredException - if invoked on a container-managed entity manager of type
PersistenceContextType.TRANSACTION and there is no
transaction.<T> T merge(T entity)
entity -
java.lang.IllegalArgumentException - if instance is not an entity or is a removed entity
TransactionRequiredException - if invoked on a container-managed entity manager of type
PersistenceContextType.TRANSACTION and there is no
transaction.void remove(java.lang.Object entity)
entity -
java.lang.IllegalArgumentException - if the instance is not an entity or is a detached entity
TransactionRequiredException - if invoked on a container-managed entity manager of type
PersistenceContextType.TRANSACTION and there is no
transaction.
<T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
entityClass - primaryKey -
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
<T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
java.util.Map<java.lang.String,java.lang.Object> properties)
entityClass - primaryKey - properties - 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
<T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode)
entityClass - primaryKey - lockMode -
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 or is null
TransactionRequiredException - if there is no transaction and a lock mode other than NONE is
set
OptimisticLockException - if the optimistic version check fails
PessimisticLockException - if pessimistic locking fails and the transaction is rolled
back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled
back
PersistenceException - if an unsupported lock call is made
<T> T find(java.lang.Class<T> entityClass,
java.lang.Object primaryKey,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
entityClass - primaryKey - lockMode - properties - standard and vendor-specific properties and hints
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 or is null
TransactionRequiredException - if there is no transaction and a lock mode other than NONE is
set
OptimisticLockException - if the optimistic version check fails
PessimisticLockException - if pessimistic locking fails and the transaction is rolled
back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled
back
PersistenceException - if an unsupported lock call is made
<T> T getReference(java.lang.Class<T> entityClass,
java.lang.Object primaryKey)
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
key or is null
EntityNotFoundException - if the entity state cannot be accessedvoid flush()
TransactionRequiredException - if there is no transaction
PersistenceException - if the flush failsvoid setFlushMode(FlushModeType flushMode)
flushMode - FlushModeType getFlushMode()
void lock(java.lang.Object entity,
LockModeType lockMode)
entity - lockMode -
java.lang.IllegalArgumentException - if the instance is not an entity or is a detached entity
TransactionRequiredException - if there is no transaction
EntityNotFoundException - if the entity does not exist in the database when pessimistic
locking is performed
OptimisticLockException - if the optimistic version check fails
PessimisticLockException - if pessimistic locking fails and the transaction is rolled
back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled
back
PersistenceException - if an unsupported lock call is made
void lock(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
entity - lockMode - properties - standard and vendor-specific properties and hints
java.lang.IllegalArgumentException - if the instance is not an entity or is a detached entity
TransactionRequiredException - if there is no transaction
EntityNotFoundException - if the entity does not exist in the database when pessimistic
locking is performed
OptimisticLockException - if the optimistic version check fails
PessimisticLockException - if pessimistic locking fails and the transaction is rolled
back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled
back
PersistenceException - if an unsupported lock call is madevoid refresh(java.lang.Object entity)
entity -
java.lang.IllegalArgumentException - if the instance is not an entity or the entity is not managed
TransactionRequiredException - if invoked on a container-managed entity manager of type
PersistenceContextType.TRANSACTION and there is no
transaction.
EntityNotFoundException - if the entity no longer exists in the database
void refresh(java.lang.Object entity,
java.util.Map<java.lang.String,java.lang.Object> properties)
entity - properties - standard and vendor-specific properties
java.lang.IllegalArgumentException - if the instance is not an entity or the entity is not managed
TransactionRequiredException - if invoked on a container-managed entity manager of type
PersistenceContextType.TRANSACTION and there is no
transaction.
EntityNotFoundException - if the entity no longer exists in the database
void refresh(java.lang.Object entity,
LockModeType lockMode)
entity - lockMode -
java.lang.IllegalArgumentException - if the instance is not an entity or the entity is not managed
TransactionRequiredException - if there is no transaction
EntityNotFoundException - if the entity no longer exists in the database
PessimisticLockException - if pessimistic locking fails and the transaction is rolled
back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled
back
PersistenceException - if an unsupported lock call is made
void refresh(java.lang.Object entity,
LockModeType lockMode,
java.util.Map<java.lang.String,java.lang.Object> properties)
entity - lockMode - properties - standard and vendor-specific properties and hints
java.lang.IllegalArgumentException - if the instance is not an entity or the entity is not managed
TransactionRequiredException - if there is no transaction
EntityNotFoundException - if the entity no longer exists in the database
PessimisticLockException - if pessimistic locking fails and the transaction is rolled
back
LockTimeoutException - if pessimistic locking fails and only the statement is rolled
back
PersistenceException - if an unsupported lock call is madevoid clear()
void detach(java.lang.Object entity)
entity -
java.lang.IllegalArgumentException - if the instance is not an entityboolean contains(java.lang.Object entity)
entity -
java.lang.IllegalArgumentException - if not an entityLockModeType getLockMode(java.lang.Object entity)
entity -
TransactionRequiredException - if there is no transaction
java.lang.IllegalArgumentException - if the instance is not a managed entity and a transaction is
active
void setProperty(java.lang.String propertyName,
java.lang.Object value)
propertyName - value -
java.lang.IllegalArgumentException - if the second argument is not valid for the implementationjava.util.Map<java.lang.String,java.lang.Object> getProperties()
java.util.Set<java.lang.String> getSupportedProperties()
Query createQuery(java.lang.String qlString)
qlString - a Java Persistence query string
java.lang.IllegalArgumentException - if the query string is found to be invalid
<T> TypedQuery<T> createQuery(java.lang.String qlString,
java.lang.Class<T> resultClass)
qlString - a Java Persistence query stringresultClass - the type of the query result
java.lang.IllegalArgumentException - if the query string is found
to be invalid<T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery)
criteriaQuery - a criteria query object
java.lang.IllegalArgumentException - if the query definition is
found to be invalidQuery createNamedQuery(java.lang.String name)
name - the name of a query defined in metadata
java.lang.IllegalArgumentException - if a query has not been defined with the given name or if the
query string is found to be invalid
<T> TypedQuery<T> createNamedQuery(java.lang.String name,
java.lang.Class<T> resultClass)
name - the name of a query defined in metadataresultClass - the type of the query result
java.lang.IllegalArgumentException - if a query has not been
defined with the given name or if the query string is
found to be invalidQuery createNativeQuery(java.lang.String sqlString)
sqlString - a native SQL query string
Query createNativeQuery(java.lang.String sqlString,
java.lang.Class resultClass)
sqlString - a native SQL query stringresultClass - the class of the resulting instance(s)
Query createNativeQuery(java.lang.String sqlString,
java.lang.String resultSetMapping)
sqlString - a native SQL query stringresultSetMapping - the name of the result set mapping
void joinTransaction()
TransactionRequiredException - if there is no transaction.<T> T unwrap(java.lang.Class<T> cls)
cls - the class of the object to be returned. This is normally
either the underlying EntityManager implementation class or an
interface that it implements.
PersistenceException - if the provider does not support the call.java.lang.Object getDelegate()
void close()
java.lang.IllegalStateException - if the EntityManager is container-managed.boolean isOpen()
EntityTransaction getTransaction()
java.lang.IllegalStateException - if invoked on a JTA EntityManager.EntityManagerFactory getEntityManagerFactory()
java.lang.IllegalStateException - if the entity manager has been closed.QueryBuilder getQueryBuilder()
java.lang.IllegalStateException - if the entity manager has been closed.Metamodel getMetamodel()
java.lang.IllegalStateException - if the entity manager has been closed.
|
EclipseLink 2.0.0_ 2.0.0.v20090626-r4569 API Reference | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||