The scenario involves quite some classes. The basic structure is something like
The problem with that model is that e.g. a query like from PolymorphicPropertyBase p left join p.base b left join b.relation1 might sometimes work whereas from PolymorphicPropertyBase p left join p.base b left join b.relation2 will not and vice versa.
The reason for this, is that during the metamodel building hibernate currently resolves p.base to the first type it encounters i.e. either PolymorphicSub1 or PolymorphicSub2. This will make it work for one type, but fail for the other.
The fix I applied is very involved in the metadata building. It detects conflicts(properties of both types) at the junction points(PolymorphicPropertyBase) and changes the properties types to the common super type. This has the effect that p.base will now resolve to PolymorphicBase which will rightfully involve a polymorphic join for all subtypes.
Applied PR upstream after some minor modifications.