syntax like this
criteriaBuilder.treat(root, SubClass.class).fetch("subClassField", JoinType.LEFT);
is not working, since only joins are present here
https://github.com/hibernate/hibernate-orm/blob/9ff14a33c78b11f03351748dfe4a5610517325f3/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/QueryStructure.java#L308
I tried to add
to the next line and it seems to work.
Maybe it was intended and I am missing something?
Looks like an oversight.
I know you're familiar with treat, what's your take on this?
could you prepare a test case using our test case template (https://github.com/hibernate/hibernate-test-case-templates/tree/master/orm/hibernate-orm-5)? Or even prepare a PR?
Indeed, this seems to be an oversight and your fix looks reasonable.
I'll try to add a test
Opened pull request