I have a situation. In my project the data model is controlled by business guy and he has created a relationship between two tables where the relationship is with a unique column on other table rather than primary key. Let me create a sample table
Table - CATEGORY
Column
ID - PK
Version -
CatergoryID - Combination of Version and this column is is Unique
Category_Desc
Table - PCM
Coulmn
ID - PK
Catergory_ID - FK to Category ID in Category Table
Version - FK to Version on Category Table
.....
.....
Now when I use hibernate to use many-to-one relationship it does not work. It does not load child Category.
I you suggest it is a bad database design. I agree with you but I can’t help, its political.
So can someone suggest me how to use this scenario with hibernate.
Use the property-ref attribute in order to specify an FK relationship by a column other than the PK in the target table.