It's not ideal, but you can work around by applying a "where" attribute like
this:

<bag name="Apples" cascade="all-delete-orphan" inverse="true"
where="EntityType='Apple'">
......

Then you bag will append tha every time, which is what is needed here.  It's
some undesirable duplication having to specify the db column and
discriminator val here when it's also in the main mapping for the "Apple"
entity, but if you can live with that, this should allow you to map your
collection of subclassed elements without getting elements of the wrong type
trying to make their way into your collection.

Good luck!
Anne


On Sat, Oct 3, 2009 at 11:40 AM, jvans <[email protected]> wrote:

>
> Just another ping to see if anyone has thoughts on this.
>
> On Sep 17, 10:17 pm, jvans <[email protected]> wrote:
> > I have encountered the same problem described in this issue, and am
> > left wondering why this was not considered an issue.
> >
> > Documentation shows the following
> >
> > (3)force (optional - defaults to false) "force" NHibernate to specify
> > allowed discriminator values even when retrieving all instances of the
> > root class.
> > The force attribute is (only) useful if the table contains rows with
> > "extra" discriminator values that are not mapped to a persistent
> > class. This will not usually be the case.
> >
> > The patch provided by the user clearly shows that his mapping was not
> > retrieving all instances of the root class, but rather the mapping was
> > asking explicitly for Apples in one collection and Oranges in the
> > other. Assuming that the table contained only items that had mappings
> > it seems that the user was obeying the rules.
> >
> > What is not clear to me is that if I specify the following
> >
> > <bag name="Oranges" cascade="all-delete-orphan" inverse="true">
> >       <key column="ContainerID"/>
> >       <one-to-many
> > class="NHibernate.Test.NHSpecificTest.NH1579.Orange, NHibernate.Test"/
> >
> > </bag>
> >
> > where I have explicitly stated that bag is to contain oranges, then
> > how does this not line up with what the documentation states? This bag
> > is to contain only Oranges, not the root class (in this case entity).
> >
> > If someone could help me to clarify this that would be most
> > appreciated. I have always assumed that a table per hierarchy would
> > allow me to map collections containing a single sub class of the
> > hierarchy in exactly the way shown above.
> >
> > Thanks much
> >
> > John
> >
>

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