FetchMode join makes no difference for ManyToMany relations in spring JPA repositories

Going through many forums and blogs to read for your problem (I guess you might have done that before posting it here) I too think that

@Fetch(FetchMode.JOIN) will be ignored if you use the Query interface
(e.g.: session.createQuery()) but it will be properly used if you use
the Criteria interface.

This is practically a bug in Hibernate which was never resolved. It is
unfortunate because a lot of applications use the Query interface and
cannot be migrated easily to the Criteria interface.

If you use the Query interface you always have to add JOIN FETCH
statements into the HQL manually.

References
Hibernate Forum
Spring Forum
Similar Question 1

Leave a Comment