Using the JPA Criteria API, can you do a fetch join that results in only one join?

Instead of root.join(...) you can use root.fetch(...) which returns Fetch<> object.

Fetch<> is descendant of Join<> but it can be used in similar manner.

You just need to cast Fetch<> to Join<> it should work for EclipseLink and Hibernate

...
Join<MyEntity, RelatedEntity> join = (Join<MyEntity, RelatedEntity>)root.fetch("relatedEntity");
...

Leave a Comment