darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
450 stars 172 forks source link

Restrict eager loading to @OneToOne and @OneToMany relationships #39

Closed darrachequesne closed 8 years ago

darrachequesne commented 8 years ago

Previously, a JOIN FETCH was also added when dealing with a relationship that may return multiple lines (@OneToMany, for example). Since Hibernate doesn't know how many lines it will need to construct your entities, it fetches a lot of lines and store them in memory, resulting in a big performance hit. In that case, the following warning is displayed: "HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!". That commit thus restricts JOIN FETCH to @OneToOne and @ManyToOne relationships.

Fixes #38