Evening guys,
I'm a little new to nhibernate and was wondering if someone could
point me in the right direction, as i may have the wrong end of the
stick, for the following:

I have a web application with database persisted settings/parameters
which I have mapped to a SiteSettings Domain object, as below:

<property name="Name" column="name" type="String" length="150" />
<property name="SiteUrl" column="homeurl" type="String" length="150" /
>
<property name="DefaultCulture" column="defaultculture" type="String"
length="10" />
<many-to-one name="DefaultCurrency" class="Currency"
column="currencyid" not-null="true" outer-join="true" />

I also wanted to access a collection of category objects from this,
representing the root elements of a category tree/hierarchy  (a
category object has many-to-one parentCategory and bag one-to-many
child categories). The root elements of the category trees are
identifiable by a parent id is 0, so I was hoping to simply add a bag
mapping to the SiteSetting object with a where clause specifying
parent id=0 as there will only ever be one sitesetting row in the
database, however it doesn't appear to be that easy as I need to have
a key mapped effectively joining the two objects.

The only way I can think how to achieve this is like this:

<bag name="RootCategories" cascade="none" where="parentcategoryid =0"
lazy="true" inverse="true">
                        <key column="sitesettingid" />
                        <one-to-many class="Category" />
                </bag>

However this would force me to add an additional field in all the
categories mapping back to the single row of sitesettings, which there
will only ever be 1

Is there anyway to tell nhibernate to simply load the root elements
into a collection for every instance of sitesetting, rather than
having it try to map via a non existent sitesettingid in category?

Sorry if this is completely balmy, but as I said...im still
learning ;-)
Would, appreciate any feedback -even if it is to say how wrong I am,

kmoo01

-- 
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