Ah....I think I see where I was going wrong.  I expected the
relationship between the Header -> LatestApprovedVersion to be a one-
to-one.

Thanks a lot!

On Feb 20, 12:56 pm, hival <[email protected]> wrote:
> I'm not sure whether it is the optimal solution but it works
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
>         assembly="NHTest" namespace="NHTest.Model" auto-import="true">
>
>         <class name="Header" table="Header">
>                 <id name="HeaderId" column="HeaderId">
>                         <generator class="native" />
>                 </id>
>
>                 <many-to-one name="LatestVersion" entity-name="LatestVersion"
>                                          column="LatestVersionId" 
> cascade="save-update" not-null="true" /
>
>
>
>                 <many-to-one name="LatestApprovedVersion" entity-
> name="LatestApprovedVersion"
>                                          column="LatestApprovedVersionId" 
> cascade="save-update" not-
> null="true" />
>         </class>
>
>         <class name="Version" entity-name="LatestVersion" table="Version">
>                 <id name="VersionId" column="VersionId">
>                         <generator class="native" />
>                 </id>
>
>                 <one-to-one name="Header" property-ref="LatestVersion"
> constrained="true" />
>         </class>
>
>         <class name="Version" entity-name="LatestApprovedVersion"
> table="Version">
>                 <id name="VersionId" column="VersionId">
>                         <generator class="native" />
>                 </id>
>
>                 <one-to-one name="Header" property-ref="LatestApprovedVersion"
> constrained="true" />
>         </class>
> </hibernate-mapping>
>
> Use constrained="true" only if the respective foreign key in the
> Header table doesn't allow null values.
> In this case NH will not use outer joins when loading Version
> association.

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