I have a user table and a user_detail
table with one to one mapping user_detail
table have a field user_id
to be used for this relation which stores id field value of corresponding user.
How to write the hibernate hbm
file for this relation?
UPDATE
what my problem is that user's primary key is id
, user_detail's foreign key is user_id
all the examples i got in internet users user_id as users primary key and the same as foreign key in other table
In the User.hbm you need to declare the relation with UserDetails like this:
<one-to-one name="user_detail" foreign-key="user_id" class="UserDetail full name "/>
Hope this help you