title: Hibernate - Subclass has to be binded after it's mother class
body: <p>after upgrading hibernate to from version <strong>4.3.7.Final</strong> to <em><strong>5.3.18.Final</strong></em> I got the error below</p>
  <pre><code>@Entity
  @Audited
  @AuditPermission(Permission.VIEW_INDIVIDUAL)
  public class Individual implements ITemporalEntity {
  
      @Id
      @Column(name = &quot;Individual_id&quot;)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;Individual_generator&quot;)
      @SequenceGenerator(name = &quot;Individual_generator&quot;, initialValue = 1, allocationSize = 1, sequenceName = &quot;Individual_id_seq&quot;)
      private Long id;
      @Embedded
      private TemporalEntity temporal = new TemporalEntity();
      @Override
      public DateTime getCreateDate() {
       return temporal.getCreateDate();
      }
  
      @Override
      public void setCreateDate(DateTime createDate) {
       temporal.setCreateDate(createDate);
  
      }
      .......
      ...
  
     }
  </code></pre>
  <p><strong>TemporalEntity</strong> class</p>
  <pre><code>@Embeddable
  public class TemporalEntity {
  
  @Column(updatable = false)
  private DateTime createDate;
  
  @Column
  private DateTime lastModifiedDate;
  
  @ManyToOne
  @JoinColumn(name = &quot;created_by_id&quot;, updatable = false)
  private AdminUser createdBy;
  
  @ManyToOne
  @JoinColumn(name = &quot;last_modified_by_id&quot;)
  private AdminUser lastModifiedBy;
  
  @Column(nullable = false, columnDefinition = &quot;boolean not null default false&quot;)
  private boolean deleted = false;
  
  public DateTime getCreateDate() {
      return createDate;
  }
  
  public void setCreateDate(DateTime createDate) {
      if (createDate == null) {
          //ignore attempts to clear this field
          return;
          //throw new IllegalStateException(&quot;Null create date not allowed&quot;);
      }
      this.createDate = createDate;
  }
  
  public DateTime getLastModifiedDate() {
      return lastModifiedDate;
  }
  
  public void setLastModifiedDate(DateTime lastModifiedDate) {
      if (lastModifiedDate == null) {
          //ignore attempts to clear this field
          return;
          //throw new IllegalStateException(&quot;Null last modified date not allowed&quot;);
      }
      this.lastModifiedDate = lastModifiedDate;
  }
  
  public AdminUser getCreatedBy() {
      return createdBy;
  }
  
  public void setCreatedBy(AdminUser createdBy) {
      if (createdBy == null) {
          //ignore attempts to clear this field
          return;
          //throw new IllegalStateException(&quot;Null created by not allowed&quot;);
      }
      this.createdBy = createdBy;
  }
  
  public AdminUser getLastModifiedBy() {
      return lastModifiedBy;
  }
  
  public void setLastModifiedBy(AdminUser lastModifiedBy) {
      if (lastModifiedBy == null) {
          //ignore attempts to clear this field
          return;
          //throw new IllegalStateException(&quot;Null lastModifiedBy not allowed&quot;);
      }
          this.lastModifiedBy = lastModifiedBy;
      }
  
      public boolean isDeleted() {
          return deleted;
      }
  
      public void setDeleted(boolean deleted) {
          this.deleted = deleted;
      }
  
  }
  </code></pre>
  <p><strong>ITemporalEntity</strong> interface</p>
  <pre><code>public interface ITemporalEntity {
  
      public DateTime getCreateDate();
  
      public void setCreateDate(DateTime createDate);
  
      public DateTime getLastModifiedDate();
  
      public void setLastModifiedDate(DateTime lastModifiedDate);
  
      public AdminUser getCreatedBy();
  
      public void setCreatedBy(AdminUser createdBy);
  
      public AdminUser getLastModifiedBy();
  
      public void setLastModifiedBy(AdminUser lastModifiedBy);
  
      public boolean isDeleted();
  
      public void setDeleted(boolean deleted);
  
  }
  </code></pre>
  <p><strong>the error stack</strong></p>
  <pre><code>an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Subclass has to be binded after it's mother class: com.berwick.dal.TemporalEntity
  23:11:29,486 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 87) MSC000001: Failed to start service jboss.persistenceunit.&quot;bds-core-1.0-SNAPSHOT.war#com.berwick.dal&quot;: org.jboss.msc.service.StartException in service jboss.persistenceunit.&quot;bds-core-1.0-SNAPSHOT.war#com.berwick.dal&quot;: org.hibernate.AssertionFailure: Subclass has to be binded after it's mother class: com.berwick.dal.TemporalEntity
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:198) [wildfly-jpa-21.0.0.Final.jar:21.0.0.Final]
  </code></pre>
  <p><strong>My tries to fix the issue</strong></p>
  <p>add <code>@MappedSuperclass</code> to TemporalEntity class
  that makes this error gone but I got more errors</p>
  <pre><code>Duplicate generator name Individual_generator you will likely want to set the property hibernate.jpa.compliance.global_id_generators to false 
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:198) [wildfly-jpa-21.0.0.Final.jar:21.0.0.Final]
  </code></pre>