Hibernate session does not save subclass information correctly when using batch size >0 and hibernate.discriminator.ignore_explicit_for_joined

Description

We have a use case to set the flag hibernate.discriminator.ignore_explicit_for_joined to true. Unfortunately we have code we can't change that uses inconsistent DiscriminatorValue's.

It seems that when hibernate.jdbc.batch_size is > 0 and hibernate.discriminator.ignore_explicit_for_joined is true, the data for the a subclass of InheritanceType.JOINED does not get saved.

I tried upgrading to 5.3.16.Final due to the fix of HHH-12968, but it did not solve my problem.

Our codebase uses hibernate 5.2.18.Final, but i created a unit test within our application to test over hibernate versions. It works as expected with hibernate 5.2.14.Final, and seems to be fixed in 5.4.10.Final.
I added a testcase derived from the template, trying to isolate the problem as much as possible.

The testcase passes with hibernate 5.4.10.Final and fails with versions between 5.2.18.Final and 5.4.10.Final.
The testcase also passes if either hibernate.discriminator.ignore_explicit_for_joined is set to false or hibernate.jdbc.batch_size is set to 0.

Due to the fact we use some external code we unfortunately can't upgrade to hibernate 5.3. In our osgi module there is a bundle dependency on org.hibernate.core bundle and this seems to have been moved to org.hibernate.orm.core).

Environment

Hibernate 5.2.18.Final Amazon Corretto JDK8

Assignee

Unassigned

Reporter

Willem Borgesius

Fix versions

None

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.14
5.4.10

Components

Affects versions

Priority

Major
Configure