java - How to define a many to one mapping in hibernate (XML based) based on non-primary key columns -
scenario:
two tables user , usergroup
sample user table desc below
name null type ------------- -------- ------------- id varchar2(12) usergroup varchar2(32) role_id not null number(5)
sample usergroup table desc below
name null type ------------------- -------- ------------- id varchar2(12) name varchar2(32) role_id not null number(5)
from above tables, usergroup + role_id
in user table linked name + role_id
in usergroup
i need write 1 many mapping above relation, can usergroup object user object. have defined below relation in user.hbm not working.
<join table="usr_group" fetch="join" optional="true"> <key property-ref="nonprimary"> <column name="name" /> </key> <many-to-one name="usergroup" column="usergroup" formula="role_id" class="someclass" entity-name="someclass" not-null="true"> </many-to-one> </join
please me on this.
Comments
Post a Comment