I’m making some modifications to a query do so some pre-fetching for performance reasons in very specific scenarios. This is a query that requires joining several tables with 1-N relationships, which are needed to be referenced in the where clause. I know that hibernate limits Join Fetch to 2 tables for 1-N relationships. After I’ve exceeded 2 Join Fetches, is it possible to join the rest of the entities with just a regular join to one of the previous entities that has been join fetched? When I attempt this, I receive an “invalid path” error, as I am trying to reference the attributes in the where clause.
Ex:
Tables: A, B, C, D, E
Fetch<A, B> abFetch = root.fetch("b", JoinType.LEFT);
Join<A, B> abJoin = (Cast) abFetch;
Fetch<B, C> bcFetch = abJoin.fetch("c", JoinType.LEFT);
Join<B, C> bcJoin = (Cast) bcFetch;
Join<C, D> cdJoin = bcJoin.join("d", JoinType.LEFT);
Join<C, E> ceJoin = bcJoin.join("e", JoinType.LEFT);
where ...
cdJoin.get("attribute"),
ceJoin.get("attribute"),
...
How am I able to join the rest of my tables?