This is by design, so I've changed this to an improvement. The AssociationKey for A.c.d.e will be the same as A.d.e, since both will involve the same table (D) with the same column (e_id). When the same AssociationKey is found, Hibernate stops walking the associations, to avoid repeating paths. Note that the extra query is not needed if either:
- A.c.d.e and A.d.e refer to the same E entity.
- A.c.d and A.d refer to the same D entity.
I suppose it may be possible to improve this, but it will need to wait until Hibernate 6 (at least). |