I have a ManyToMany association:
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
name="SITE_PROG_PARTNER_XREF",
joinColumns = @JoinColumn(name = "SITE_ID", referencedColumnName = "SID"),
inverseJoinColumns = @JoinColumn(name = "PARTNER_ID")
)
private Set<ProgrammaticPartnerModel> programmaticPartners = new HashSet<>();
I am using Spring Data’s PagingAndSortingRepository vanilla findAll(Pageable) method and for each record Hibernate is issuing a query to populate ManyToMany association. That happens before findAll() returns and I traced it down to org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter#getResultList method.
So it seems that FetchType.LAZY is ignored.
Hibernate Version: 5.1.17
UPDATE: I found the issue and it was not a problem with Hibernate. We had custom implementation of org.hibernate.Interceptor that was inspecting some properties during onLoad() event and that was triggering collection fetch