0
我有以下表NHibernate的三元關係映射
CREATE TABLE track
ID
name
CREATE TABLE people
ID
firstname
CREATE TABLE role
ID
name
CREATE TABLE track_people_role
track_id
people_id
role_id
和下面的映射文件
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="App.Data.BusinessObjects" assembly="App.Data">
<class name="App.Data.BusinessObjects.Track, App.Data" table="track" lazy="true">
<id name="Id" column="ID">
<generator class="native" />
</id>
<property name="Name" column="name" />
</class>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="App.Data.BusinessObjects" assembly="App.Data">
<class name="App.Data.BusinessObjects.People, App.Data" table="people" lazy="true">
<id name="Id" column="ID">
<generator class="native" />
</id>
<property name="Firstname" column="firstname" />
</class>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="App.Data.BusinessObjects" assembly="App.Data">
<class name="App.Data.BusinessObjects.Role, App.Data" table="role" lazy="true">
<id name="Id" column="ID">
<generator class="native" />
</id>
<property name="Name" column="name" />
</class>
我很難嘗試配置track_people_role表的映射。有人能幫我嗎?
我在中間表中有下面的行。主鍵是三列的組合。
track_id people_id role_id 14292 1 1 14292 1 2 track_id people_id role_id 1200 1 1 1200 2 1
嗨迭戈,我更新我原來的帖子,包括一些示例行。隨着你的解決方案track.PeopleRoles只返回第一行,當我試圖保存(14292,1,3)我得到了「一個具有相同的密鑰項目已被添加」錯誤 – Guray 2011-02-11 18:15:35