java - How to write many to one relationship for below scenario hibernate -
user table
id -pk name groupname roleid
usergroup
id -pk name description roleid
in above tables, groupname , roleid non-primary fields in user table has relationship name , roleid in usergroup table
question here is : how write many 1 relationship(user->usergroup) in user.hbm.xml
consider searching "hibernate @onetoone example".
regarding foreign keys, consider keeping usergroup_id in user table instead of "groupname".
Comments
Post a Comment