# Hibernate Revenge Mapping error

**URL:** <https://discourse.hibernate.org/t/hibernate-revenge-mapping-error/10368>\
**Category:** Hibernate Tools\
**Created:** [September 22, 2024, 10:35am UTC](https://discourse.hibernate.org/t/hibernate-revenge-mapping-error/10368 "2024-09-22T10:35:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonardo\_Civinini](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/leonardo_civinini/32/3489_2.png) [@Leonardo\_Civinini](https://discourse.hibernate.org/u/Leonardo_Civinini)\
**Post date:** [September 22, 2024, 10:35am UTC](https://discourse.hibernate.org/t/hibernate-revenge-mapping-error/10368/1 "2024-09-22T10:35:57Z")

</div>

Hi,  
migrating from Hibernate 5 to Hibernate 6, I noticed a problem generating ManyToOne code when two classes have a CompositeId and the key columns are not lexicographically ordered.  
In my case table2 with a primary key (d\_ins, c\_app, n\_seq) has a foreign key on table1, with primary (d\_ins, c\_app): table 2 FOREIGN KEY (d\_ins, c\_app) REFERENCES table1 (d\_ins, c\_app) .  
This is the generated code

```auto
type or paste code here

@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumns( { 
        @JoinColumn(name="d_ins", referencedColumnName="c_app", nullable=false, insertable=false, updatable=false), 
        @JoinColumn(name="c_app", referencedColumnName="d_ins", nullable=false, insertable=false, updatable=false) } )
    public Teme50CheTrn getTeme50CheTrn() {
        return this.teme50CheTrn;
    }

```

I don’t know if this coud help further analysis, but in Component.getType() method there is setProperties(true) call, that sort primary key columns in lexicographically order
