Spring Boot 2.0.0 M6 - Add Hibernate Interceptor

前端 未结 3 1763
星月不相逢
星月不相逢 2021-01-05 09:03

After upgrade from Spring Boot 2.0.0 M2 to 2.0.0 M6 my Hibernate interceptor implementation don\'t work anymore.

My old implementation:

@Configuratio         


        
3条回答
  •  無奈伤痛
    2021-01-05 09:49

    I can solve this with this documentation:

    Add support for advanced customization of Hibernate settings

    Just implements a interface HibernatePropertiesCustomizer

    and implements methods customize(Map hibernateProperties)

    @Component
    class MyHibernateInterceptorCustomizer implements HibernatePropertiesCustomizer {
    
        @Autowired
        MyInterceptor myInterceptor
    
        @Override
        void customize(Map hibernateProperties) {
           hibernateProperties.put("hibernate.session_factory.interceptor", myInterceptor);
        }
    }

提交回复
热议问题