-
Notifications
You must be signed in to change notification settings - Fork 40.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@EnableBatchProcessing doesn't work with @DataJpaTest #10703
Comments
I would suggest to move Regarding your tests, I think you should create the right annotation to load batch infrastructure to work with jpa. |
Yes, moving the What do you mean by creating the right annotation to load batch infrastructure? |
True but the thing that's missing there is that So |
@arthurc I've created a separate issue to improve that section with what I've just explained. |
Ahh, I see. I'll make sure not to clutter my main application class with additional |
Hello I am facing the same issue. I would like to test my batch by populating data and next run the job using jobLauncherTestUtils. I am using TestEntityManager persistAndFlush method to save my data. It is working only if I remove all stuff from SpringBatch however I get this error javax.persistence.TransactionRequiredException: no transaction is in progress I"ve defined @DataJpaTest, @AutoConfigureTestEntityManager, @EnableBatchProcessing in other configuration classes with no luck. So basically, is it possible to use @DataJpaTest with batch ? If yes how can it be done ? Thanks by advance. Regards, Damien |
@dcdh this issue is closed and we don't use the tracker for questions. Please ask on StackOverflow or join us on Gitter. |
I had a hard time trying to make Spring Batch work with JPA and Junit. The issue javax.persistence.TransactionRequiredException: no transaction is in progress has been occuring all the time. |
@pawelwloch There was nothing to resolve in Spring Boot itself. The problem above was that If you have any further questions, please follow up on Stack Overflow. |
If I use @EnableBatchProcessing on a configuration class and then try to write a test with @DataJpaTest, the test blows up when EntityManager#flush() is invoked and throws the following error:
I have put up a minimal project that illustrates a the issue over at https://github.com/arthurc/spring-boot-datajpatest-and-batch. Notice that if @EnableBatchProcessing is removed from https://github.com/arthurc/spring-boot-datajpatest-and-batch/blob/master/src/main/java/com/example/jpaandbatch/JpaAndBatchApplication.java then test (PersonTest) works fine.
The issue is in 1.5.8 and I've managed to backtrack the issue as far back as Spring Boot 1.4.2.
The text was updated successfully, but these errors were encountered: