Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: Build 1.2.0.GA
I'm attempting to map the following:
Staff object: A staff object maintains a collection of roles
Code:
IList<StaffRole> staffRoles;
A StaffRole object maintains a link to the role type
Code:
IStaffRole role;
This all appears to work fine until I do something like this
Code:
foreach(StaffRole r in someStaffMember.Roles) {
Console.WriteLine(r.Role.GetType());
}
Now I would have thought that it would print something like
SomeNameSpace.Project.ModuleLeaderRole;but instead it prints
ProxyInterfaceSystemSystemObject_ProxyInHibernateProxy_System_Runtime_SerializationMy question is, how can I (if its possible) get the call to GetType to return the correct type of object.
The important bits of mapping files look like
Interface mapping file
Code:
<class name="IStaffRole" table="Role">
<id name="RoleID" column="RoleID" type="Int32">
<generator class="native" />
</id>
<discriminator column="RoleName" type="String"/>
<subclass name="ModuleLeaderRole" discriminator-value="ModuleLeaderRole">
<property name="RoleName" column="RoleName" type="String"/>
<property name="Description" column="Description" type="String" />
</subclass>
</class>
Staff Role Mapping file
Code:
<class name="StaffRole" table="StaffInRoles">
<id name="StaffInRoleID" column="StaffInRoleID" type="int">
<generator class="native"></generator>
</id>
<many-to-one name="Staff" column="StaffID" not-null="true"/>
<many-to-one name="Role" column="RoleID" not-null="true" class="IStaffRole"/>
</class>
Collection of roles from Staff Mapping file
Code:
<bag name="StaffRoles" lazy="true" cascade="save-update" inverse="false" >
<key column="StaffID"/>
<one-to-many class="StaffRole"/>
</bag>
Many thanks if anybody can shed some light on this.[/b]