Pablo, I've the same problem.
If you specify the many-to-one relation before de join its works. But,
the column was created in your animal table instead of the dog table.
Try this
Animal.hbm.xml
.........
<discriminator column="animal_type" type="string"/>
<property name="Name" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="name" not-null="true" />
</property>
<subclass name="Dog, Business, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" discriminator-value="1" >
<many-to-one class="Person, Business, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" name="Owner" not-null="true">
<column name="owner_id" not-null="true" />
</many-to-one>
<join table="dog">
<key>
<column name="animal_id" />
</key>
</join>
</subclass>
<subclass name=Whale, Business, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" discriminator-value="2">
</subclass>
If somebody find another solution please show us.
Thanks.
On 31 ago, 00:44, Pablo Romano <[email protected]> wrote:
> Thanks Diego, I took your recommendation and used table-per-subclass;
> it was my initial approach but I thought in this case mixed
> inheritance would be better performing, I'll look for a workaround, if
> anyone solved this before please let me know.
>
> Thanks again for the answer!
>
> Pablo
>
>
>
> On Sun, Aug 29, 2010 at 10:38, Diego Mijelshon <[email protected]> wrote:
> > I'm not sure that's possible... have you considered switching to either
> > table-per-subclass (<joined-subclass>) or plain table-per-class-hierarchy?
>
> > Diego
>
> > On Sat, Aug 28, 2010 at 18:41, Pablo Romano <[email protected]> wrote:
>
> >> Hi,
> >> I'm having a problem when using a bag of a subclass (with mixed
> >> inheritance), nhib seems to be looking at the foreign-key in the base
> >> class and, in this case, it's on the subclass. Is there any way of
> >> telling nhib to look for the field on the joined table?
>
> >> This is an example of the mappings:
>
> >> Animal.hbm.xml
> >> .........
> >> <discriminator column="animal_type" type="string"/>
> >> <property name="Name" type="System.String, mscorlib,
> >> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
> >> <column name="name" not-null="true" />
> >> </property>
> >> <subclass name="Dog, Business, Version=1.0.0.0, Culture=neutral,
> >> PublicKeyToken=null" discriminator-value="1" >
> >> <join table="dog">
> >> <key>
> >> <column name="animal_id" />
> >> </key>
> >> <many-to-one class="Person, Business, Version=1.0.0.0,
> >> Culture=neutral, PublicKeyToken=null" name="Owner" not-null="true">
> >> <column name="owner_id" not-null="true" />
> >> </many-to-one>
> >> </join>
> >> </subclass>
> >> <subclass name=Whale, Business, Version=1.0.0.0, Culture=neutral,
> >> PublicKeyToken=null" discriminator-value="2">
> >> </subclass>
> >> ..........
>
> >> Person.hbm.xml
> >> ..................
> >> <bag name="Dogs" >
> >> <key>
> >> <column name="owner_id" />
> >> </key>
> >> <one-to-many class="Dog, Business, Version=1.0.0.0,
> >> Culture=neutral, PublicKeyToken=null" />
> >> </bag>
> >> ........
>
> >> Thanks in advance,
> >> Pablo
>
> >> --
> >> 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.
>
> > --
> > 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.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
--
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.