| We partially got around this by using the @Fetch(FetchMode.SUBSELECT) annotation above any @OneToMany or @ManyToMany mappings. This will lazily load all child entities for all required rows in one db call using the original query with any required joins. Not a perfect solution but it does manage to avoid the Cartesian product and the infamous N + 1 issue for these cases. However, this isn't supported for @OneToOne or @ManyToOne mappings so there's no real solution for those cases as far as I see it other than accepting N + 1 queries. |