Hi

What you think about:

* Your middle table having 3 columns, 1 PK and 2 FKs:
- PK id iddentity
- FK id_table1 int
- FK id_table2 int

On database, create an alternative key using UNIQUE INDEX on
id_table1,id_table2 ?

best regards

Wilker





2011/1/6 Mickael <[email protected]>

> Hi,
>
> I have a many-to-many association between two entities : Engineer and
> Skills. A Engineer is unique in is domain and skill as well so the
> primary key of both these entities are composite-key of their id and
> the domain id.
>
> So the primary key for engineer is id and domain_id and for skill is
> id and domain_id.
>
> In the many to many association between skill and engineer I should
> have a table with engineer_id, skill_id and domain_id as a primary
> key.
>
> I can't find how to tell NHibernate the domain_id is only one column.
>
> For the moment I have this mapping which duplicate the domain_id
> colum.
>
>  <class name="Skill" table="Skill" lazy="false">
>    <composite-id>
>      <key-property name="Id" column="id"/>
>      <key-property name="Domain_Id" column="domain_id"/>
>    </composite-id>
>    <version name="Version" column="version"/>
>    <property name="Description" column="description"/>
>  </class>
>
>  <class name="Engineer" table="Engineer" lazy="false">
>    <composite-id>
>      <key-property name="Id" column="id"/>
>      <key-property name="Domain_Id" column="domain_id"/>
>    </composite-id>
>    <version name="Version" column="version"/>
>    <property name="Description" column="description"/>
>    <set name="Skills" table="Engineer_Skill" lazy="false"
> cascade="all">
>      <key>
>        <column name="resource_type_id"/>
>        <column name="domain_id1"/>
>      </key>
>      <many-to-many class="Skill">
>        <column name="skill_id"/>
>        <column name="domain_id2"/>
>      </many-to-many>
>    </set>
>  </class>
>
> Any idea how to solve this problem ?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to