| 
 | The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.orm.jpa.EntityManagerFactoryAccessor
org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor
public class OpenEntityManagerInViewInterceptor
Spring web request interceptor that binds a JPA EntityManager to the thread for the entire processing of the request. Intended for the "Open EntityManager in View" pattern, i.e. to allow for lazy loading in web views despite the original transactions already being completed.
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. It inherits common JPA configuration properties from
 JpaAccessor, to be configured in a
 bean definition.
OpenEntityManagerInViewFilter, 
JpaInterceptor, 
JpaTransactionManager, 
JpaTemplate.execute(org.springframework.orm.jpa.JpaCallback), 
SharedEntityManagerCreator, 
TransactionSynchronizationManager| Field Summary | |
|---|---|
| static String | PARTICIPATE_SUFFIXSuffix that gets appended to the EntityManagerFactory toString representation for the "participate in existing entity manager handling" request attribute. | 
| Fields inherited from class org.springframework.orm.jpa.EntityManagerFactoryAccessor | 
|---|
| logger | 
| Constructor Summary | |
|---|---|
| OpenEntityManagerInViewInterceptor() | |
| Method Summary | |
|---|---|
|  void | afterCompletion(WebRequest request,
                Exception ex)Callback after completion of request processing, that is, after rendering the view. | 
| protected  String | getParticipateAttributeName()Return the name of the request attribute that identifies that a request is already filtered. | 
|  void | postHandle(WebRequest request,
           ModelMap model)Intercept the execution of a request handler after its successful invocation, right before view rendering (if any). | 
|  void | preHandle(WebRequest request)Intercept the execution of a request handler before its invocation. | 
| Methods inherited from class org.springframework.orm.jpa.EntityManagerFactoryAccessor | 
|---|
| createEntityManager, getEntityManagerFactory, getJpaPropertyMap, getTransactionalEntityManager, setEntityManagerFactory, setJpaProperties, setJpaPropertyMap | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final String PARTICIPATE_SUFFIX
| Constructor Detail | 
|---|
public OpenEntityManagerInViewInterceptor()
| Method Detail | 
|---|
public void preHandle(WebRequest request) throws DataAccessException
WebRequestInterceptorAllows for preparing context resources (such as a Hibernate Session) and expose them as request attributes or as thread-local objects.
preHandle in interface WebRequestInterceptorrequest - the current web request
DataAccessExceptionpublic void postHandle(WebRequest request, ModelMap model)
WebRequestInterceptorAllows for modifying context resources after successful handler execution (for example, flushing a Hibernate Session).
postHandle in interface WebRequestInterceptorrequest - the current web requestmodel - the map of model objects that will be exposed to the view
 (may be null). Can be used to analyze the exposed model
 and/or to add further model attributes, if desired.public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException
WebRequestInterceptorNote: Will only be called if this interceptor's preHandle
 method has successfully completed!
afterCompletion in interface WebRequestInterceptorrequest - the current web requestex - exception thrown on handler execution, if any
DataAccessExceptionprotected String getParticipateAttributeName()
PARTICIPATE_SUFFIX| 
 | The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||