Well I've almost solved the problem.
Now the mapping looks like:

  <class name="HierarchyItem">
    <composite-id >
      <key-property name="Hierarchy" column="HierarchyId"/>
      <key-property name="ItemId"  column="ItemId"/>
    </composite-id>

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

    <property name="ParentItemIdPrivate" column="ParentItemId"
access="field.camelcase-underscore"/>

    <many-to-one name="ParentItem" class="HierarchyItem" insert="false"
update="false">
      <column name="HierarchyId" />
      <column name="ParentItemId" />
    </many-to-one>
  </class>

The problem now is that when ParentItemId is null I get
ObjectNotFoundException.
If I specify not-found="ignore" then it forces loading all hierarchy up
(i.e. all parents until the root).
Is it possible to fix it somehow?

On Tue, Jan 19, 2010 at 12:28 PM, Petr Syromolotov <
[email protected]> wrote:

> Hello
>
> I have following mapping:
>
>   <class name="HierarchyItem">
>     <composite-id >
>       <key-property name="Hierarchy" column="HierarchyId"/>
>       <key-property name="ItemId"  column="ItemId"/>
>     </composite-id>
>
>     <many-to-one name="Hierarchy" column="HierarchyId" insert="false"
> update="false"></many-to-one>
>
>     <many-to-one name="ParentItem" class="HierarchyItem">
>       <column name="HierarchyId" />
>       <column name="ParentItemId" />
>     </many-to-one>
>   </class>
>
> The problem is that this mapping does not work - it generates
> "IndexOutOfRangeException" because columns "HierarchyId" is specified twice.
> I can not put insert="false" update="false" to second <many-to-one> tag.
> Is there any way to specify these options (insert="false" update="false")
> only for       <column name="HierarchyId" /> but not to entire <many-to-one>
> tag?
>
> PS I know that DB design is not good here but I can't do anything with
> this.
>
>
--
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