spring data jpa and hibernate n+1 selects on manytoone column
posted 8 months ago
I am using spring data jpa, hibernate, and mysql. When I load an entity with a manytoone column, hibernate is issuing multiple select statements. This article seems to explain the issue a bit, and claims that eager fetching should never be used.
We are not having performance issues, so I wasn't planning on optimizing and returning only the data needed in each query, however I would like to fix the n+1 issue.
How can I instruct hibernate/spring jpa to use a join instead of multiple selects?