Hi,
I have two tables User and Role and a composite table UserRole having primary key ad UserId,RoleId and foreign keys to UserId and RoleId.
I have created classes and mapping files as billow, and retrieve roles for user using many-to-many relation,
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Core.Modules.Security.DomainModel.User, Core" table="SYSUSER" lazy="false" >
<id name="_userCode" column="USERCODE" access="field" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="_userFullName" column="USERFULLNAME" access="field"/>
<property name="_userTypeNum" column="USERTYPENUM" access="field"/>
<bag name="_role" access="field" table="USERROLES" lazy="false" inverse="true" cascade="all" collection-type="Core.HelperClasses.CustomCollections.ObservableList`1[[Core.Modules.Security.DomainModel.Role, Core]], Core">
<key column="USERCODE" />
<many-to-many class="Core.Modules.Security.DomainModel.Role, Core" column="ROLECODE"/>
</bag>
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Core.Modules.Security.DomainModel.Role, Core" table="SYSROLE" lazy="false">
<id name="_id" column="ROLECODE" access="field" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="_roleDesc" column="ROLEDESC" access="field" not-null="false"/>
</class>
</hibernate-mapping>
This works fine and gets me user with all hos roles. Now I have a column called IdDefault in UserRole table which tells me what is the default role of the user.
How do i retrieve this data from the UserRole table since i don't have any mapping to this table
Thanks
Arvind