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

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 -