FETCH JOIN is still a JOIN

JPA’s FETCH JOIN is useful in cases when you want to eagerly load some lazy loaded collection of your entity. By default all @OneToMany and @ManyToMany relationships are lazy loaded. There are some valid cases when (despite the settings in your mapped entity), you want to eagerly load the related entity. One of the way of doing it is to use JOIN FETCH JPQL clause. It’s worth remembering that JOIN FETCH is used mainly because of its side-effect of populating the pointed relationship – it’s still a JOIN and must be treated like it when it comes to the duplicated result set problem....

October 5, 2012 · 3 min