If A has a constraint where B must exist and B has a constraint where A must
exist and the only way to know a POID using identity is storing a record how
you can do it ?

In some case, in NH, you can use <inverse> to define the "owner"of the
relationship.
Advise:
1) don't send a generated mapping because it is not human-readable
2) don't use "native" if native=identity
3) don't use composite-key if you don't need it (in your case there is only
one field)
4) have a look to :
<generator class="foreign">
<param name="property">Foo</param>
</generator>

2010/1/25 Chris C <[email protected]>

> If I have a pair of tables that have a one-to-one relation between
> them, how do I control the order in which they are saved (i.e. define
> which is the parent)?
>
> Currently NHibernate keeps trying to save "Bar" before it has saved
> "Foo" and thus either fails due to a foreign key violation when using
> something like "guid.comb" or null key error if using something like
> "native".
>
> The mapping I have so far is listed below, the example source is at
> http://gist.github.com/285899
>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> access="property" auto-import="true" default-cascade="none" default-
> lazy="true">
>  <class xmlns="urn:nhibernate-mapping-2.2" name="ValueMapping.Foo,
> ValueMapping, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> table="`Foo`">
>    <id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Id" />
>      <generator class="native" />
>    </id>
>    <one-to-one cascade="all" class="ValueMapping.Bar, ValueMapping,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> constrained="true" foreign-key="none" name="Bar" />
>    <property name="Name" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Name" />
>    </property>
>  </class>
>
>  <class xmlns="urn:nhibernate-mapping-2.2" name="ValueMapping.Bar,
> ValueMapping, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> table="`Bar`">
>    <composite-id mapped="false" unsaved-value="undefined">
>      <key-many-to-one name="Foo" class="ValueMapping.Foo,
> ValueMapping, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
>        <column name="Foo" />
>      </key-many-to-one>
>    </composite-id>
>    <property name="Rate" type="System.Int32, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Rate" />
>    </property>
>    <property name="Value" type="System.Int32, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Value" />
>    </property>
>  </class>
> </hibernate-mapping>
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
Fabio Maulo

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