org.springframework.orm.jpa.support

Class OpenEntityManagerInViewFilter

    • Constructor Detail

      • OpenEntityManagerInViewFilter

        public OpenEntityManagerInViewFilter()
    • Method Detail

      • setEntityManagerFactoryBeanName

        public void setEntityManagerFactoryBeanName(@Nullable
                                                    java.lang.String entityManagerFactoryBeanName)
        Set the bean name of the EntityManagerFactory to fetch from Spring's root application context.

        Default is "entityManagerFactory". Note that this default only applies when no "persistenceUnitName" param has been specified.

        See Also:
        setPersistenceUnitName(java.lang.String), DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME
      • getEntityManagerFactoryBeanName

        @Nullable
        protected java.lang.String getEntityManagerFactoryBeanName()
        Return the bean name of the EntityManagerFactory to fetch from Spring's root application context.
      • setPersistenceUnitName

        public void setPersistenceUnitName(@Nullable
                                           java.lang.String persistenceUnitName)
        Set the name of the persistence unit to access the EntityManagerFactory for.

        This is an alternative to specifying the EntityManagerFactory by bean name, resolving it by its persistence unit name instead. If no bean name and no persistence unit name have been specified, we'll check whether a bean exists for the default bean name "entityManagerFactory"; if not, a default EntityManagerFactory will be retrieved through finding a single unique bean of type EntityManagerFactory.

        See Also:
        setEntityManagerFactoryBeanName(java.lang.String), DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME
      • getPersistenceUnitName

        @Nullable
        protected java.lang.String getPersistenceUnitName()
        Return the name of the persistence unit to access the EntityManagerFactory for, if any.
      • shouldNotFilterAsyncDispatch

        protected boolean shouldNotFilterAsyncDispatch()
        Returns "false" so that the filter may re-bind the opened EntityManager to each asynchronously dispatched thread and postpone closing it until the very last asynchronous dispatch.
        Overrides:
        shouldNotFilterAsyncDispatch in class OncePerRequestFilter
      • shouldNotFilterErrorDispatch

        protected boolean shouldNotFilterErrorDispatch()
        Returns "false" so that the filter may provide an EntityManager to each error dispatches.
        Overrides:
        shouldNotFilterErrorDispatch in class OncePerRequestFilter
      • lookupEntityManagerFactory

        protected EntityManagerFactory lookupEntityManagerFactory(HttpServletRequest request)
        Look up the EntityManagerFactory that this filter should use, taking the current HTTP request as argument.

        The default implementation delegates to the lookupEntityManagerFactory without arguments, caching the EntityManagerFactory reference once obtained.

        Returns:
        the EntityManagerFactory to use
        See Also:
        lookupEntityManagerFactory()
      • lookupEntityManagerFactory

        protected EntityManagerFactory lookupEntityManagerFactory()
        Look up the EntityManagerFactory that this filter should use.

        The default implementation looks for a bean with the specified name in Spring's root application context.

        Returns:
        the EntityManagerFactory to use
        See Also:
        getEntityManagerFactoryBeanName()