Hibernate 5 migration Issue with Multilevel JOINED table Inheritance with Hibernate 5.4 DiscriminatorColumn

I am working on migrating a legacy Hibernate project from version 4.1 to 5.4 . The code has Multilevel Joined table inheritance using a dedicated DiscriminatorColumn . The code was working fine in Hibernate 4 but throwing errors in Hibernate 5.

Here is the detailed issue on slackoverflow.

Inheritance is like this:

Strangely, The question didn’t receive any responses so far in there. Hope It’ll get some answers here at least.

Hibernate 5.4 is not “supported” anymore. Can you try the same on 5.6 please and tell us if the problem persists?

Thank you, @beikov for the response. The issue remains same after upgrading to Hibernate 5.6.8.Final version too.

Could you also please test whether the problem persists with Hibernate 6.0? Either way, you can create a JIRA issue for this bug against the 5.6.8 version.

Hmm… Ok, I will give it a try with 6.0 and update you.

Finally, it’s resolved after removing all the @DiscriminatorColumn & @DiscriminatorValue annotations on all the classes. Looks like hibernate 5 is strict with the annotations. Now, the generated joined query for retrieving records is similar to Hibernate 4. It uses a special column named clazz using case statement to determine the inheritance type. This column will be used by hibernate internally.