1

I'm using latest springframework disto v4.2.5.RELEASE and Hibernate v5.0.7.Final when spring loads EntityManagerFactory i'm getting the below exception

Caused by: org.hibernate.HibernateException: Not all named super-types (extends) were found : [com.sample.model.Sample]
at org.hibernate.boot.model.source.internal.hbm.EntityHierarchyBuilder.buildHierarchies(EntityHierarchyBuilder.java:76)
at org.hibernate.boot.model.source.internal.hbm.HbmMetadataSourceProcessorImpl.<init>(HbmMetadataSourceProcessorImpl.java:66)
at org.hibernate.boot.model.source.internal.hbm.HbmMetadataSourceProcessorImpl.<init>(HbmMetadataSourceProcessorImpl.java:40)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.<init>(MetadataBuildingProcess.java:142)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:141)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319)

The same code was working with v4.2.5.RELEASE and Hibernate v.4.3.10.

I know Hibernate changed core metadata building in v5.x, is there anything needs to be specified in spring config of JPA/EntityManagerFactory/Hibernate Properties to make it work with Hibernate 5.x?

@Entity
@Table(name = "tbl_sample")
public class Sample extends Auditable {
  private Long id;
  @ManyToOne
  @JoinColumn(name = "relationA", nullable = true)
  private RelationA relationA;
  ... etc
}

@MappedSuperClass
public abstract class Auditable extends Persistable {
   //audit props
}

@MappedSuperClass
public abstract class Persistable {
   //common props
}

I could able to narrow down the issue after enabling trace log, there was one more class which is extending Sample Class and its mapped using hbm.xml like below

<hibernate-mapping package="com.sample.model">  
  <joined-subclass name="BloodSample" table="tbl_blood_sample"
   extends="com.sample.model.Sample">
   <key column="ID" />

  <property name="sampleNo" column="sampleNo"/>
   etc....
 </joined-subclass>

The moment i removed this relation hbm it started working... Still wondering why its happening now which was not in older version of hibernate.

So i guess this issue is nothing to do with spring but something related hibernate. Any insight ?

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
Sreekanth
  • 539
  • 1
  • 7
  • 24

1 Answers1

0

I have a similar your issue. You try to class tag instead joined-subclass tag in hbm.xml file