Reputation: 722
Via JPA Criteria Api
Join
can in turn be joined either via Join.join(...)
or via Join.fetch(...)
.Fetch
in turn can only be joined via Fetch.fetch(...)
:What is the reason? Why an attribute of a fetched entity in turn can not be joined (without fetch)?
For example:
root.join(entity1_attribute, JoinType.INNER)
.join(entity2_attribute, JoinType.INNER)
.fetch(entity3_attribute, JoinType.INNER)
is possible.
But
root.join(entity1_attribute, JoinType.INNER)
.fetch(entity2_attribute, JoinType.INNER)
.join(entity3_attribute, JoinType.INNER) //<--
is not possible.
Upvotes: 0
Views: 48
Reputation: 16400
It is this way for the same reason that the JPQL BNF does not allow aliasing fetch joins, because nested fetches do not have to be supported according to the JPA specification. You can ask on the JPA mailing list or create an issue to request making Fetch
extend Join
or something like that if you want.
Upvotes: 1