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
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