public class OpenEntityManagerInViewInterceptor extends EntityManagerFactoryAccessor implements org.springframework.web.context.request.AsyncWebRequestInterceptor
This interceptor makes JPA EntityManagers available via the current thread,
which will be autodetected by transaction managers. It is suitable for service
layer transactions via JpaTransactionManager
or JtaTransactionManager as well
as for non-transactional read-only execution.
In contrast to OpenEntityManagerInViewFilter, this interceptor
is set up in a Spring application context and can thus take advantage of
bean wiring.
OpenEntityManagerInViewFilter,
JpaTransactionManager,
SharedEntityManagerCreator,
TransactionSynchronizationManager| Modifier and Type | Field and Description |
|---|---|
static String |
PARTICIPATE_SUFFIX
Suffix that gets appended to the EntityManagerFactory toString
representation for the "participate in existing entity manager
handling" request attribute.
|
logger| Constructor and Description |
|---|
OpenEntityManagerInViewInterceptor() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterCompletion(org.springframework.web.context.request.WebRequest request,
Exception ex) |
void |
afterConcurrentHandlingStarted(org.springframework.web.context.request.WebRequest request) |
protected String |
getParticipateAttributeName()
Return the name of the request attribute that identifies that a request is
already filtered.
|
void |
postHandle(org.springframework.web.context.request.WebRequest request,
org.springframework.ui.ModelMap model) |
void |
preHandle(org.springframework.web.context.request.WebRequest request) |
createEntityManager, getEntityManagerFactory, getJpaPropertyMap, getPersistenceUnitName, getTransactionalEntityManager, setBeanFactory, setEntityManagerFactory, setJpaProperties, setJpaPropertyMap, setPersistenceUnitNamepublic static final String PARTICIPATE_SUFFIX
public void preHandle(org.springframework.web.context.request.WebRequest request)
throws org.springframework.dao.DataAccessException
preHandle in interface org.springframework.web.context.request.WebRequestInterceptororg.springframework.dao.DataAccessExceptionpublic void postHandle(org.springframework.web.context.request.WebRequest request,
org.springframework.ui.ModelMap model)
postHandle in interface org.springframework.web.context.request.WebRequestInterceptorpublic void afterCompletion(org.springframework.web.context.request.WebRequest request,
Exception ex)
throws org.springframework.dao.DataAccessException
afterCompletion in interface org.springframework.web.context.request.WebRequestInterceptororg.springframework.dao.DataAccessExceptionpublic void afterConcurrentHandlingStarted(org.springframework.web.context.request.WebRequest request)
afterConcurrentHandlingStarted in interface org.springframework.web.context.request.AsyncWebRequestInterceptorprotected String getParticipateAttributeName()
PARTICIPATE_SUFFIX