|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.cayenne.jpa.ResourceLocalEntityManager
public class ResourceLocalEntityManager
| Field Summary | |
|---|---|
protected ObjectContext |
context
|
protected ResourceLocalEntityManagerFactory |
factory
|
protected FlushModeType |
flushMode
|
protected boolean |
open
|
protected EntityTransaction |
transaction
|
| Constructor Summary | |
|---|---|
ResourceLocalEntityManager(ObjectContext context,
ResourceLocalEntityManagerFactory factory)
|
|
| Method Summary | ||
|---|---|---|
protected void |
checkAttached(Object entity)
Checks if an entity is attached to the current EntityManager, throwing IllegalArgumentException if not. |
|
protected void |
checkClosed()
Throws an exception if called on closed factory. |
|
protected void |
checkNotRemoved(Object entity)
Checks if an entity is not removed in the current EntityManager, throwing IllegalArgumentException if it is. |
|
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. |
|
Query |
createNamedQuery(String name)
Create an instance of Query for executing a named query (in EJB QL or native SQL). |
|
Query |
createNativeQuery(String sqlString)
Create an instance of Query for executing a native SQL statement, e.g., for update or delete. |
|
Query |
createNativeQuery(String sqlString,
Class resultClass)
|
|
Query |
createNativeQuery(String sqlString,
String resultSetMapping)
Create an instance of Query for executing a native SQL query. |
|
Query |
createQuery(String ejbqlString)
Create an instance of Query for executing an EJB QL statement. |
|
|
find(Class<T> entityClass,
Object primaryKey)
Find by primary key. |
|
void |
flush()
Synchronize the persistence context to the underlying database. |
|
DataChannel |
getChannel()
Returns a DataChannel of the peer ObjectContext. |
|
Object |
getDelegate()
|
|
protected ResourceLocalEntityManagerFactory |
getFactory()
Returns parent EntityManagerFactory. |
|
FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained in the persistence context. |
|
|
getReference(Class<T> entityClass,
Object primaryKey)
Get an instance, whose state may be lazily fetched. |
|
EntityTransaction |
getTransaction()
Return the resource-level transaction object. |
|
boolean |
isOpen()
|
|
void |
joinTransaction()
Indicates to the EntityManager that a JTA transaction is active. |
|
void |
lock(Object entity,
LockModeType lockMode)
|
|
|
merge(T entity)
Merge the state of the given entity into the current persistence context. |
|
void |
persist(Object entity)
Make an instance managed and persistent. |
|
void |
refresh(Object entity)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any. |
|
void |
remove(Object entity)
Remove the entity instance. |
|
void |
setFlushMode(FlushModeType flushMode)
Set the flush mode that applies to all objects contained in the persistence context. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected EntityTransaction transaction
protected ResourceLocalEntityManagerFactory factory
protected FlushModeType flushMode
protected boolean open
protected ObjectContext context
| Constructor Detail |
|---|
public ResourceLocalEntityManager(ObjectContext context,
ResourceLocalEntityManagerFactory factory)
| Method Detail |
|---|
public DataChannel getChannel()
getChannel in interface CayenneEntityManagerprotected ResourceLocalEntityManagerFactory getFactory()
public void close()
IllegalStateException - if the EntityManager is associated with an active
transaction or if the EntityManager is container-managed.public boolean isOpen()
public Object getDelegate()
public void persist(Object entity)
entity - an object to be made persistent
IllegalArgumentException - if not an entity.public <T> T merge(T entity)
entity -
IllegalArgumentException - if instance is not an entity or is a removed
entitypublic void remove(Object entity)
entity -
IllegalArgumentException - if not an entity or if a detached entity.
public <T> T find(Class<T> entityClass,
Object primaryKey)
entityClass - primaryKey -
IllegalArgumentException - if the first argument does not denote an entity
type or the second argument is not a valid type for that
public <T> T getReference(Class<T> entityClass,
Object primaryKey)
entityClass - primaryKey -
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
EntityNotFoundException - if the entity state cannot be accessedpublic void flush()
PersistenceException - if the flush failspublic void setFlushMode(FlushModeType flushMode)
flushMode - public FlushModeType getFlushMode()
public void refresh(Object entity)
entity -
IllegalArgumentException - if not an entity or entity is not managed
EntityNotFoundException - if the entity no longer exists in the databasepublic void clear()
public boolean contains(Object entity)
IllegalArgumentException - if not an entitypublic Query createQuery(String ejbqlString)
ejbqlString - an EJB QL query string
IllegalArgumentException - if query string is not validpublic Query createNamedQuery(String name)
name - the name of a query defined in metadata
IllegalArgumentException - if a query has not been defined with the given
name
public Query createNativeQuery(String sqlString,
Class resultClass)
public Query createNativeQuery(String sqlString)
sqlString - a native SQL query string
public Query createNativeQuery(String sqlString,
String resultSetMapping)
sqlString - a native SQL query stringresultSetMapping - the name of the result set mapping
public void joinTransaction()
This implementation throws a JpaProviderException, as it only supports resource-local operation.
JpaProviderException - as this impementation only supports resource-local
operation.
public void lock(Object entity,
LockModeType lockMode)
public EntityTransaction getTransaction()
protected void checkAttached(Object entity)
throws IllegalArgumentException
IllegalArgumentException
protected void checkNotRemoved(Object entity)
throws IllegalArgumentException
IllegalArgumentException
protected void checkClosed()
throws IllegalStateException
IllegalStateException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||