Vlad K Vlad K - 27 days ago 11
Java Question

Eclipselink fetch-join lazy associations of a subclass

I want to fetch a lazy association, which is present on a subclass only.
In Hibernate, it is possible to use fetch treat joins, for example

select a from A a left join fetch treat(a.parent as Child) u left join fetch child.some


Where
child.some
is an association which is present on
Child
entity only.

But we use Eclipselink ver 2.6.3. AFAIK JPA doesn't cover this problem, fetch treat is not supported by Eclipse. I have already tried eclipse fetch hints with no success.

Thanks in advance

Answer

This is not supported in EclipseLink by default (I believe it is a bug). But there is working workaround in Joiner library (InheritanceJoiningCustomizer in https://github.com/encircled/Joiner)