Hibernate upgrade from 5.6.15 to 6.5.2 - Mapping Issue

Facing the below issue with ORM mapping of hbm.xml files after upgrading from 5.6.15 to 6.5.2

Below image has mapping and the POJOs

Issue:
After parsing User.hbm.xml, User’s id and addr are missing from the mapping. However, acct was added with this component’s property name - id. CriteriaAPI queries that were running fine with previous version (5.6.15) are failing with the new version because of the missing component names (addr and acct).
Error thrown: org.hibernate.query.sqm.PathElementException: Could not resolve attribute ‘addr’ of ‘org.example.Account’

Observation:
declaredSingularAttributes of AbstractManagedType does not have these mappings. Attributes are added to declaredSingularAttributes with name as the key.

All the attributes are considered normal properties of User, even the properties under Components. User’s id, addr, and acct all have the property name ‘id’, hence only one mapping exists, the latest parsed attribute.

Is there any workaround to this issue? Also, is this a bug in the newer versions from version 6.

Hello @KCMT, I belive the problem here is you’re extending a class (IDEntity) which is not @MappedSuperclass from your component classes. This is not allowed by JPA, and while it might have worked with previous Hibernate versions, Hibernate 6 will ignore the properties coming form the superclass in this case.

Thank you @mbladel for the response. Facing the same issue even after using the annotation @MappedSuperclass on IDEntity class. Also, the issue here seems to be with mapping logic. user.hbm.xml is has three properties with different column names but with same name, id. From hibernate 6, mapping seems to be based on the names even though the properties are enclosed in a component. Could this be an issue with Hibernate 6?

It might be, but note that the hbm.xml format is deprecated and will no longer be supported in future versions of Hibernate.

I would suggest trying to migrate to the supported orm.xml format (see for example this discussion on how to use the semi-automatic xml transformer), or even better to annotated classes.