Get org.hibernate.LazyInitializationException in spring boot integration test
<p>I'm trying to write integration test for Spring Boot application. I have Product and GalleryImage domain model. They are in one-to-many relationship.</p>

<pre><code>public class Product {
    ...

    @OneToMany(mappedBy = "product")
    private List&lt;GalleryImage&gt; galleryImages;
}
</code></pre>

<p>I have a integration test as below:</p>

<pre><code>@Test
public void testProductAndGalleryImageRelationShip() throws Exception {
    Product product = productRepository.findOne(1L);
    List&lt;GalleryImage&gt; galleryImages = product.getGalleryImages();
    assertEquals(1, galleryImages.size());
}
</code></pre>

<p>However, this test gives me a LazyInitializationException. I searched on Google and StackOverFlow, it says that the session is closed after productRepository.findOne(1L), since galleryImages are lazily loaded, so galleryImages.size() gives me this exception.</p>

<p>I have tried to add a @Transactional annotation on the test, but it's still not working.</p>