Persist for entity using JOINED inheritance, batch_size > 1 and legacy ID generation does not work in Hibernate

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.2
  • Hibernate 5.3

Issue

  • An entity hierarchy is defined using JOINED inheritance:

        @Entity
        @Inheritance(strategy = InheritanceType.JOINED)
        public class Person {
            @Id
            @GeneratedValue
            private Long id;
            ...
        }
    
        @Entity
        public class Employee extends Person {
            ...
        }
    
  • The persistence unit is configured to use JDBC batching and legacy ID generation:

            ...
            <property name="hibernate.jdbc.batch_size" value="20" />
            <property name="hibernate.id.new_generator_mappings" value="false" />
            ...
    
  • In a batch of several entities persisted in a transaction, the final entity is not persisted fully

  • The base class may be persisted but not the leaf class

Resolution

This issue1 is resolved in This content is not included.EAP 7.2 cumulative patch (CP) 5 and later releases. Production systems should use the latest available cumulative patch.

Root Cause

This is a known defect (Content from hibernate.atlassian.net is not included.HHH-13602).

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.