Hibernate spring.jpa.mapping-resources=hibernate.cfg.xml not read after Spring-Boot 2.1.0


#1

I logged the following issue on Spring Boot issue tracker and have now been directed here.

Spring-Boot 2.0.8 adds the mappings by creating entities from the *hbm.xml files listed in spring.jpa.mapping-resources=hibernate.cfg.xml, Any release after that ignores the mapping file.

javax.persistence.metamodel.Metamodel metaModel = emf.getMetamodel();
Set<EntityType<?>> entityTypeSet = metaModel.getEntities();

https://github.com/spring-projects/spring-boot/issues/15824

https://hibernate.atlassian.net/browse/HHH-12871

HH12871 has been implicated as reason why our mapped classes are no longer ending up as EntityType.

We have mappings and use the EntityType created by Hibernate to get hold of its Attributes and their JavaType.

EntityType persistEntityType = iceEntityManager.get(persistEntityName);
        Attribute persistAttribute = persistEntityType.getAttribute(attributeName);
        Class persistAttributeJavaTypeClass = persistAttribute.getJavaType();

Previously this was no problem at all.
In our project there just is no difference between the mapped classes and the annotated
@Entity classes. Why should there be a difference?


#2

If you can replicate it using this test case, you should open a Jira issue.


#3

Thanks. Created jira issue. https://hibernate.atlassian.net/browse/HHH-13250


#4

Thanks. Now, since you investigated the issue, you should try to provide a fix. Send us a Pull Request and we will investigate it afterward.


#5

Sure… in a perfect world where i have time to figure out all the Hibernate internals. In the meantime i’ll stick to that release until i can squeeze it no further.


#6

I surely understand what you mean since we also don’t have the resources to fix all the issues and since HBM mappings are considered deprecated, this issue does not have a high priority.