We have a Spring Boot 2.4.5 application that uses a custom EmptyInterceptor
. This interceptor is working in both the application and the tests where both the onSave
and onFlushDirty
methods are being executed properly.
We just updated to Boot which also upgrades Hibernate and JUnit along with many other libraries (details below). With this upgrade, our application still works as expected but for some reason, the interceptor's onSave
and onFlushDirty
methods are not being executed. We do see other interceptor methods being executed so we can assume that the interceptor is properly registered.
I've been combing through release notes for Spring, Spring JPA, and Hibernate but can't find anything that appears to be related to how this works. Is there something we're missing as part of the upgrade that may be related to changing the way the interceptor works?
Technical details:
Our custom interceptor:
@Component
public class AuditedEntityInterceptor extends EmptyInterceptor implements BeanFactoryAware
.. which is then wired into the application by:
@Configuration
@Slf4j
public class HibernateInterceptorConfig implements HibernatePropertiesCustomizer {
@Autowired
private AuditedEntityInterceptor auditedEntityInterceptor;
//...
@Override
public void customize(Map<String, Object> hibernateProperties)
{
hibernateProperties.put("hibernate.session_factory.interceptor", auditedEntityInterceptor);
//...
}
}
I'm trying to not overload this question with too much detail but it's probably important how our integration tests are configured:
// Each single integration test is structured like:
@Transactional
public class SomethingSomethingServiceIT extends AppSharedIT
@SpringBootTest(classes = { AppSharedItConfig.class })
public abstract class AppSharedIT extends AppSupportHsqlIT
@SpringBootTest(classes = AppSupportItConfig.class)
@Sql(scripts = {
// ... a bunch of SQL scripts to initialize reference data
})
@Transactional
@ActiveProfiles(profiles = { "test" })
public abstract class AppHsqlIT implements BeanFactoryAware
@Configuration
@EnableAutoConfiguration(exclude = { QuartzAutoConfiguration.class })
@Import({ AppSupportConfig.class })
@ComponentScan(basePackages = {
//...
})
public class AppSupportItConfig
@Configuration
@EnableTransactionManagement
@EntityScan({
//...
})
@EnableJpaRepositories({
//...
})
@ComponentScan(
basePackages = {
//...
})
@Import(value = { //...
HibernateInterceptorConfig.class })
public class AppSupportConfig
Among many other libraries, I've been focusing on the following version changes:
junit-jupiter: 5.7.1 -> 5.8.2
spring-boot: 2.4.5 -> 2.7.4
hibernate-core: 5.4.30.Final -> 5.6.11.Final