Now, in hibernate-core 5.2.15 these issues seem to be fixed. However, a new one arises.
You can simply reproduce it by changing EntityA to use FetchType.EAGER instead of FetchType.LAZY in your JoinedInheritanceTest like so:
WildFly 11/12, Java 9
I'll explain what is happening for documentaiton purposes. Since eager fetching is activated it tries to pre-render the SQL for the entities during boot time. Before the fix, a random Type (i.e. one of the attribute types from one of the subtypes) is registered for attributes like relation or attributes on BaseEntity. This means that, when loading BaseEntity via entityManager.find(BaseEntity.class, 123) it would be random, which one of the relations is loaded. With the fix, we register null to signal that the attribute has to be handled specially. Apparently, I missed to handle this properly for this kind of usage. I only handled the usage in queries.
I have a fix for this here: https://github.com/hibernate/hibernate-orm/pull/2190
I'm still waiting for this matter being discussed on the mailing list. Could you test it and give me feedback? I hope this will be the last problem. The code in the PR reverts back to non-determinism in some edge cases like before.
I merged your fix in hibernate-core-5.2.16-snapshot and can confirm that it works correctly again. Thanks for fixing it, great work.
Will your fix be contained in 5.2.16? And if so, when will 5.2.16 be released?
Greets to Austria
5.2.16 will contain the fix for this issue and I'm planning to release it by the end of this week.
if you have time can you please give a try to https://github.com/hibernate/hibernate-orm/pull/2208, it is a variation of the original PR.
Thanks a lot
Hi Andrea Boriero,
I also merged your modified fix and things are still working. So I would stop now. Remember: everything should be made as simple as possible, but not simpler.
Greets to London