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

Solution Verified - Updated -

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

Environment

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

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content