title: Lazy loading doesn't work for OneToMany relationship on Spring Boot
body: <p>I've been working with spring boot data jpa + spring + mysql + thymeleaf and have encountered a problem.
  Is a <code>@OneToMany (fetch = FetchType.LAZY)</code> relationship for a list, the list loads hibernate like <code>@OneToMany (fetch = FetchType.EAGER)</code> outside. But if I use the annotation <code>@ManyToOne</code> this does work perfectly.</p>
  
  <p>Any idea why it happens this behavior?
  By the way, I want to keep the spring.jpa.open-in-view = true property. I debug an application Author - Book (<code>One to Many</code>) developed in <code>IntelliJ IDEA</code>.</p>
  
  <p>Here's the Book class.</p>
  
  <pre><code>@Entity
  public class Book implements Serializable {
     @Id
     @GeneratedValue
     private Integer id;
  
     @NotNull
     private String name;
  
     @NotNull
     @JoinColumn(name = "author_id")
     @ManyToOne(fetch = FetchType.LAZY)
     private Author author;
  
    /* getters and setters */
  }
  </code></pre>
  
  <p>Here the class Author</p>
  
  <pre><code>@Entity
  public class Author implements Serializable {
     @Id
     @GeneratedValue
     private Integer id;
  
     @NotNull
     private String name;
  
     @OneToMany(mappedBy = "author", fetch = FetchType.LAZY)
     private List&lt;Book&gt; bookList;
  
     /* getters and setteres */
  }
  </code></pre>
  
  <p>The controller for debug.</p>
  
  <pre><code>@Controller
  @RequestMapping("/")
  public class HomeController {
  
      @Autowired
      private AuthorRepository authorRepository;
  
      @Autowired
      private BookRepository bookRepository;
  
      @GetMapping
      private ModelAndView index() {
          List&lt;Author&gt; authorList = authorRepository.findAll();
          return new ModelAndView("home"); // first breakpoint
      }
  
      @GetMapping("/books")
      private ModelAndView viewBooks() {
          List&lt;Book&gt; bookList = bookRepository.findAll();
          return new ModelAndView("books"); // second breakpoint
      }
  
  }
  </code></pre>
  
  <p>Here's the result.</p>
  
  <p>First breakpoint result
  <a href="https://i.stack.imgur.com/oArYW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oArYW.png" alt="First breakpoint result"></a></p>
  
  <p>Second breakpoint result
  <a href="https://i.stack.imgur.com/JgYDm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JgYDm.png" alt="Second breakpoint result"></a></p>