Here is the mapping I've here:
Code:
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.0">
<class name="Model.Board, Model" table="Boards" >
<id name="Id" access="nosetter.camelcase-underscore" column="BoardId" type="Int32" unsaved-value="0">
<generator class="native">
</generator>
</id>
<property name="_locationUnitId" access="field" column="LocationId" type="Int32" />
<property name="_createdById" access="field" column="CreatedBy" type="Int32" />
<property name="Name" access="property" column="BoardName" type="System.String" />
<property name="Description" access="property" column="BoardDescription" type="System.String" />
<property name="StartDate" access="property" column="BoardStartDate" type="System.DateTime" />
<property name="EndDate" access="property" column="BoardEndDate" type="System.DateTime" />
<property name="DateCreated" access="property" column="DateCreated" type="System.DateTime" />
<property name="Status" access="property" column="BoardStatus" type="Byte" />
<property name="BaseAssignmentLocked" access="nosetter.camelcase-underscore" column="BaseAssignmentLocked" type="Boolean" />
<many-to-one name="BoardTemplate" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" class="Model.BoardTemplate, Model" column="BoardTemplateId" />
<set name="Shifts" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" table="Shifts" inverse="true" >
<key column="BoardID" />
<one-to-many class="Model.Shift, Model" />
</set>
<set name="Rules" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" table="Rules" inverse="true" cascade="all" >
<key column="RuleEntityId" />
<many-to-any id-type="Int32" >
<column name="ShouldBeClass" />
<column name="ShouldBeId" />
</many-to-any>
</set>
</class>
</hibernate-mapping>
The SQL that NHibernate generates looks like this:
Code:
SELECT rules0_.RuleEntityId as RuleEnt10___, rules0_.ShouldBeClass as RuleEnti9___, rules0_.ShouldBeId as ShouldBeId__ FROM Rules rules0_ WHERE rules0_.RuleEntityId=@p0
What I /wants/ it to do is to select by the class as well, so it would loads only the rules that relates to a board.