Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-17485

[GSS] (7.2.z) HHH-12968 Persist fails when using JOINED Inheritance with batch_size > 1 and legacy ID generation

XMLWordPrintable

    • +
    • Hide

      Remove the <property name="hibernate.jdbc.batch_size" value="50" /> from persistence.xml

      Show
      Remove the <property name="hibernate.jdbc.batch_size" value="50" /> from persistence.xml
    • Hide

      I 'm attaching the reproducer.

      1. Deploy the reproducer.
      2. Configure and start the SQLServer 2016 or 2017
      3. Send a POST request to localhost:8080/employee sending the employee as JSON.

      Note that the issue is not unique to the database and is already described (and reproducible in pure-Hibernate testing) as detailed in HHH-13602

      Show
      I 'm attaching the reproducer. Deploy the reproducer. Configure and start the SQLServer 2016 or 2017 Send a POST request to localhost:8080/employee sending the employee as JSON. Note that the issue is not unique to the database and is already described (and reproducible in pure-Hibernate testing) as detailed in HHH-13602

      I have two entity (Person and Employee) and Employee extends Person. Look this.

      @Entity
      @Inheritance(strategy = InheritanceType.JOINED)
      public class Person implements Serializable {
      
          @Id
          @GeneratedValue
          private Long id;
      
          @Column
          private String name;
      
          public Long getId() {
              return id;
          }
      
          public void setId(Long id) {
              this.id = id;
          }
      
          public String getName() {
              return name;
          }
      
          public void setName(String name) {
              this.name = name;
          }
      
          @Override
          public boolean equals(Object o) {
              if (this == o) return true;
              if (o == null || getClass() != o.getClass()) return false;
              Person person = (Person) o;
              return id.equals(person.id);
          }
      
          @Override
          public int hashCode() {
              return Objects.hash(id);
          }
      }
      
      @Entity
      public class Employee extends Person {
      
          @Column
          private String role;
      
          public String getRole() {
              return role;
          }
      
          public void setRole(String role) {
              this.role = role;
          }
      }
      

      When I try to persist Employee entity the Person is persisted but the Employee is not persisted. Below is my persistence.xml:

      <persistence>
          <persistence-unit name="javaee8">
      
              <jta-data-source>MSSQLDS</jta-data-source>
              <properties>
                  <property name="javax.persistence.schema-generation.database.action" value="update" />
              </properties>
              <class&gt;net.rhuanrocha.entity.Employee</class&gt;
              <class&gt;net.rhuanrocha.entity.Person</class&gt;
              <exclude-unlisted-classes>true</exclude-unlisted-classes>
              <properties>
                  <property name="hibernate.jdbc.batch_size" value="50" />
                  <property name="hibernate.connection.isolation" value="2" />
                  <property name="hibernate.id.new_generator_mappings" value="false" />
                  <property name="hibernate.hbm2ddl.jdbc_metadata_extraction_strategy" value="individually" />
              </properties>
      
          </persistence-unit>
      </persistence>
      

      If I remove the <property name="hibernate.jdbc.batch_size" value="50" /> or use normal ID generation (rather than the legacy generation algorithm) it works fine.

      The below was noted in the logs.

      14:51:40,743 DEBUG [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-1) could not log warnings: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_COMMITTED
      	at org.jboss.jca.adapters.jdbc.WrapperDataSource.checkTransactionActive(WrapperDataSource.java:248)
      	at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransactionActive(WrappedConnection.java:1933)
      	at org.jboss.jca.adapters.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:1948)
      	at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1922)
      	at org.jboss.jca.adapters.jdbc.WrappedConnection.getWarnings(WrappedConnection.java:1064)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.handleAndClearWarnings(SqlExceptionHelper.java:290)
      	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logAndClearWarnings(SqlExceptionHelper.java:269)
      	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.releaseConnection(LogicalConnectionManagedImpl.java:194)
      	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.afterStatement(LogicalConnectionManagedImpl.java:149)
      	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.afterStatementExecution(JdbcCoordinatorImpl.java:279)
      	at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.releaseStatements(AbstractBatchImpl.java:158)
      	at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.release(AbstractBatchImpl.java:195)
      	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:184)
      	at org.hibernate.internal.AbstractSharedSessionContract.close(AbstractSharedSessionContract.java:324)
      	at org.hibernate.internal.SessionImpl.closeWithoutOpenChecks(SessionImpl.java:432)
      	at org.hibernate.internal.SessionImpl.close(SessionImpl.java:418)
      	at org.jboss.as.jpa.transaction.TransactionUtil$SessionSynchronization.safeCloseEntityManager(TransactionUtil.java:181)
      	at org.jboss.as.jpa.transaction.TransactionUtil$SessionSynchronization.afterCompletion(TransactionUtil.java:163)
      	at org.jboss.as.txn.service.internal.tsr.JCAOrderedLastSynchronizationList.afterCompletion(JCAOrderedLastSynchronizationList.java:144)
      

      Also noticed that if several entities are persisted in a transaction all but the final entity seem to be persisted correctly.

        1. standalone.xml
          31 kB
          Rhuan Rocha

              gbadner@redhat.com Gail Badner (Inactive)
              rhn-support-rhsilva Rhuan Rocha (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: