Mapping issue-upgrading hibernate from 5.6.15 to 6.5.2 – Component’s property with same name as one of entity’s property was not mapped in new version

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

Below are the the POJOs

public class IDEntity
{
    protected T id;
    public T getId() {return id;}
    public void setId(T id){ this.id = id; }
}

public class Address extends IDEntity 
{
    protected String address;
    protected String postalCode;
    protected String town;

    public String getAddress() { return address1; }
    public void setAddress(String address1) {this.address1 = address1;}
    public String getPostalCode(){return postalCode;}
    public void setPostalCode(String postalCode){this.postalCode = postalCode;}
    public String getTown(){return town;}
    public void setTown(String town){this.town = town;}
}

public class Account extends IDEntity 
{
    protected String accountName;
    public String getAccountName(){return accountName;}
    public void setAccountName(String accountName){this.accountName = accountName;}
}

public class User extends IDEntity 
{
    protected String userName;
    protected Address addr;
    protected Account acct;

    public String getUserName(){return userName;}
    public void setUserName(String userName){this.userName = userName;}
    public String getAddr(){return addr;}
    public void setAddr(String addr){this.addr = addr;}
    public String getAcct(){return acct;}
    public void setAcct(String acct){this.acct = acct;}
}


Below is the User.hbm.xml file

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
 "-//Hibernate/Hibernate Mapping DTD//EN"
 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 

<hibernate-mapping>
   <class name="org.example.User" table="payment" polymorphism="explicit">
      <id name="id" type="string" column="id" length="64">
            <generator class="org.example.KeyGenerator">
            </generator>
      </id>
      
      <property name="userName" column="user_name" type="string" length="64"/>
      
      <component name="addr" class="org.example.Address">
        <property column="address_id" name="id" type="string" length="64"/>
      </component>

      <component name="acct" class="org.example.Account">
        <property column="account_id" name="id" type="string" length="64"/>
      </component>

   </class>
</hibernate-mapping>

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’

I had gone through the documentation and searched in different forums and SO but didn’t find any documentation on this or posts with similar issue.

I debugged and found 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.

New contributor

user26617849 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật