Open Anshelen opened 3 years ago
I got it working with @DataJpaTest
with the following test config (JUnit 5):
@ExtendWith(SpringExtension.class)
@DataJpaTest
@ComponentScan(basePackages = { "com.yannbriancon" }) // hibernateQueryInterceptor
class RepositoryTest {
@Autowired
private HibernateQueryInterceptor hibernateQueryInterceptor;
// .....
}
Solution is working. Thanks!
For tests with @DataJpaTest HibernateQueryInterceptor is not registered automatically.
I can not load it somehow cause it is package visible only. Also I tried to add spring.jpa.properties.hibernate.session_factory.interceptor=com.yannbriancon.interceptor.HibernateQueryInterceptor, but without effect. The possible workaround is to copy-paste HibernatePropertiesConfig and add @Import({HibernateQueryInterceptor.class, HibernatePropertiesConfig.class}) to test class