Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 130857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:00:51+00:00 2026-05-11T06:00:51+00:00

I’m using nHibernate to map an object very similar to .NET’s System.Web.SiteMapNode. In order

  • 0

I’m using nHibernate to map an object very similar to .NET’s System.Web.SiteMapNode. In order to keep my object similar to this .NET object I would like to have it contain a ParentNode, PreviousSibling, NextSibling, and ChildNodes complex properties.

The table looks somewhat like this and is open to be changed:

  • ID (int)
  • Title (string)
  • Description (string)
  • Key (string)
  • ParentNodeId (int)
  • OrdinalPosition (int)
  • ReadOnly (bool)
  • Url (string)

I may have some other properties that are not needed to mimic the .NET SiteMapNode object (like an isExternal bool), but I think those are inconsequential to this question.

My current mapping looks like this:

<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' namespace='AthletesCafe.Core.Domain.System.SiteMap' assembly='AthletesCafe.Core'> <class name='SiteMapNode' table='SiteMapNode' lazy='true' >  <id name='ID' type='Int32' unsaved-value='0'>   <column name='ID' not-null='true' unique='true' index='PK_SiteMapNode'/>   <generator class='identity' /> </id>  <property name='Title' column='Title' type='String' length='255' not-null='true' /> <property name='Description' column='Description' type='String' not-null='false' />  <property name='Url' column='Description' type='String' not-null='true'  />  <property name='SiteMapKey' column='SiteMapKey' type='String' not-null='true' length='255'  />  <property name='OrdinalPosition' column='OrdinalPosition' type='Int32' not-null='true' />  <property name='ReadOnly' column='ReadOnly' not-null='true' type='System.Boolean' />  <property name='IsExternal' column='IsExternal' not-null='true' type='System.Boolean' />  <many-to-one name='ParentNode' column='ParentNodeId' class='AthletesCafe.Core.Domain.System.SiteMap.SiteMapNode, AthletesCafe.Core'               access='field.pascalcase-underscore' not-null='false' /> <many-to-one name='PreviousNode' column='ParentNodeId' class='EatMyTrainer.Core.Domain.SiteMap.SiteMapNode, EatMyTrainer.Core' not-null='false' /></hibernate-mapping> 

The ParentNode mapping is easy as it should be just a simple many-to-one mapping. This is the code I have for it (untested, but I believe it to be correct):

<many-to-one name='ParentNode' column='ParentNodeId' class='AthletesCafe.Core.Domain.System.SiteMap.SiteMapNode, AthletesCafe.Core'               access='field.pascalcase-underscore' not-null='false' /> 

The mapping for the child nodes should just be a simple bag which will bring back all SiteMapNode objects that have the ParentNodeId equal to the current ID. I haven’t written this bag yet, but I believe it to be not such a big deal.

The issue that I cannot seem to resolve is how to do the Next/Previous Sibling properties. This objects can be derived from the following formula for each node:

  • PreviousSibling: Has the same ParentNode (ParentNodeId) as the current object and its OrdinalPosition should be one less than the current object’s OrdinalPosition.
  • NextSibling: Has the same ParentNode (ParentNodeId) as the current object and its OrdinalPosition should be one more than the current object’s OrdinalPosition.

I think this is achievable through the formual attribute on a many-to-one mapping. Is this possible? I haven’t found a good example of how this works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:00:51+00:00Added an answer on May 11, 2026 at 6:00 am

    I don’t think what you’re asking for is strictly possible (although I would be very interested to see the solution if it is). There would be a relatively simple workaround, but NHibernate does not support bidirectional one-to-many mappings with indexed collections on the many end.

    The only thing that comes to mind is a bit ugly: have the parent object keep its own index map (keyed off the OrdinalPosition) to each child object. On the child do something like:

    public SiteMapNode NextSibling() {     return this.Parent.NextSibling(this); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This forum post recommends updating your web.config to allow anon… May 12, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer You can also use id which is any type of… May 12, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer Finally, I find the answer and it was pretty easy.… May 12, 2026 at 12:56 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.