I have created two entities Book
and Book_Category
with one-to-many relationship. When I issued BookCategoryRepository.findAll()
, I ex
Hibernate uses by default a second query to retriev the child collection. One reason for this is a proper limit query. Otherwise, there would be more rows in the result set, than entities for the 1 side, if at least one has more than 1 child.
There exists an annotation to change this behaviour in hibernate which is ignored by the Spring Data Jpa Repositories. The annotation is @Fetch(FetchMode.JOIN)
. You might consider How does the FetchMode work in Spring Data JPA if you really need this behaviour.