Issue
I had an Hibernate lazy loading issue when using Postman to send a reqeust derectly to a Springboot service endpoint, which is bacause I have a collection marked as FetchType.Lazy in an entity and this issue can be resolved by marking the service method as @Transactional
.
However, if I remove that @Transactional
, my Springboot controller test still passed without any Hibernate lazy loading issue.
This looks like all of the Springboot controller integration tests are always transactional. But I couldn't find any official document about it. So, my question is, is it correct?
For my integration test, I use the annotations below
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource(locations = "classpath:application.properties")