Well
Looks like I've  resolved my problem.
At least everything workds as I expect.

Mapping:

  <class name="HierarchyItem">
    <composite-id >
      <key-property name="Hierarchy" column="HierarchyId"
access="field.camelcase-underscore"/>
      <key-property name="ItemId"  column="ItemId"/>
    </composite-id>

    <many-to-one name="Hierarchy" column="HierarchyId" insert="false"
update="false"></many-to-one>

    <property name="ParentItemId" column="ParentItemId"
access="field.camelcase-underscore" />
    <many-to-one name="ParentItem" class="HierarchyItem" insert="false"
update="false"   access="field.camelcase-underscore">
      <column name="HierarchyId" />
      <column name="ParentItemId" />
    </many-to-one>
  </class>

And the class:

public class HierarchyItem
{
private int _hierarchyId
private int? _parentItemId;
private HierarchyItem _parentItem;

public virtual int ItemId
{
get;
private set;
}

public virtual Hierarchy Hierarchy
{
get;
private set;
}

public virtual HierarchyItem ParentItem
{
get
{
if(_parentItemId==null)
return null;
return _parentItem;
}
set
{
if(value==null)
{
_parentItemId=null;
}
else
{
_parentItemId=value.Id;
}
_parentItem=value;
}
}

A bit tricky but it works for me.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.

Reply via email to