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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -