I am wanting to convert a many-to-many mapping to a one-to-many link table, one-to-many style connection
I am attempting to convert a Project-ProjectUsers-User style connection where ProjectUsers is a link table but I am suffering from stupid user syndrome.
So if I have the following mapping (again unsure if this is correct).
How do I simply add users to a Project.
Code:
<id name="Project" column="ProjectId" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<bag name="ProjectUsers" cascade="all-delete-orphan" lazy="true" inverse="true">
<key column="ProjectId" />
<one-to-many class="ProjectUser, ProjectUser" />
</bag>
-------------------------------------------------------------------------------------------
<id name="ProjectUser" column="ProjectUserId type="Int32" unsaved-value="0"
<generator class="native" />
</id>
<many-to-one name="Project" column="ProjectId" class="Project,Project" />
<many-to-one name="User" column="UserId" class="User, User" />
-------------------------------------------------------------------------------------------
<id Usercolumn="UserId" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<bag name="UserProjects" cascade="all-delete-orphan" lazy="true" inverse="true">
<key column="ProjectUserId" />
<one-to-many class="ProjectUser, ProjectUser" />
</bag>
-------------------------------------------------------------------------------------------
If anyone could point me to some sample code that is doing many-to-many via two one-to-many's that would be great.
Thanks,
Jason