The JtaEntityManager is a wrapper around an entity manager that automatically creates and closes entity managers
for each transaction in which it is accessed. This implementation supports both transaction and extended scoped
JTA entity managers.
It is important that extended scoped entity managers add entity managers to the JtaEntityManagerRegistry when the
component is entered and remove them when exited. If this registration is not preformed, an IllegalStateException
will be thrown when entity manger is used.
It is important that a component adds extended scoped entity managers to the JtaEntityManagerRegistry when the
component is entered and removes them when exited. If this registration is not preformed, an IllegalStateException will
be thrown when entity manger is accessed.
Method from org.apache.openejb.persistence.JtaEntityManager Detail: |
public void clear() {
if (!extended && !isTransactionActive()) {
return;
}
getEntityManager().clear();
}
|
public void close() {
}
|
public boolean contains(Object entity) {
return isTransactionActive() && getEntityManager().contains(entity);
}
|
public Query createNamedQuery(String name) {
EntityManager entityManager = getEntityManager();
Query query = entityManager.createNamedQuery(name);
return proxyIfNoTx(entityManager, query);
}
|
public Query createNativeQuery(String sqlString) {
EntityManager entityManager = getEntityManager();
Query query = entityManager.createNativeQuery(sqlString);
return proxyIfNoTx(entityManager, query);
}
|
public Query createNativeQuery(String sqlString,
Class resultClass) {
EntityManager entityManager = getEntityManager();
Query query = entityManager.createNativeQuery(sqlString, resultClass);
return proxyIfNoTx(entityManager, query);
}
|
public Query createNativeQuery(String sqlString,
String resultSetMapping) {
EntityManager entityManager = getEntityManager();
Query query = entityManager.createNativeQuery(sqlString, resultSetMapping);
return proxyIfNoTx(entityManager, query);
}
|
public Query createQuery(String qlString) {
EntityManager entityManager = getEntityManager();
Query query = entityManager.createQuery(qlString);
return proxyIfNoTx(entityManager, query);
}
|
public T find(Class<T> entityClass,
Object primaryKey) {
EntityManager entityManager = getEntityManager();
try {
return entityManager.find(entityClass, primaryKey);
} finally {
closeIfNoTx(entityManager);
}
}
|
public void flush() {
assertTransactionActive();
getEntityManager().flush();
}
|
public EntityManager getDelegate() {
return getEntityManager();
}
|
public FlushModeType getFlushMode() {
EntityManager entityManager = getEntityManager();
try {
return entityManager.getFlushMode();
} finally {
closeIfNoTx(entityManager);
}
}
|
public T getReference(Class<T> entityClass,
Object primaryKey) {
EntityManager entityManager = getEntityManager();
try {
return entityManager.getReference(entityClass, primaryKey);
} finally {
closeIfNoTx(entityManager);
}
}
|
public EntityTransaction getTransaction() {
throw new IllegalStateException("A JTA EntityManager can not use the EntityTransaction API. See JPA 1.0 section 5.5");
}
|
public boolean isOpen() {
return true;
}
|
public void joinTransaction() {
}
|
public void lock(Object entity,
LockModeType lockMode) {
assertTransactionActive();
getEntityManager().lock(entity, lockMode);
}
|
public T merge(T entity) {
assertTransactionActive();
return getEntityManager().merge(entity);
}
|
public void persist(Object entity) {
assertTransactionActive();
getEntityManager().persist(entity);
}
|
public void refresh(Object entity) {
assertTransactionActive();
getEntityManager().refresh(entity);
}
|
public void remove(Object entity) {
assertTransactionActive();
getEntityManager().remove(entity);
}
|
public void setFlushMode(FlushModeType flushMode) {
EntityManager entityManager = getEntityManager();
try {
entityManager.setFlushMode(flushMode);
} finally {
closeIfNoTx(entityManager);
}
}
|