Hi Fabio,

I just got the JIRA ticket entered.  It's 1579 - 
http://jira.nhibernate.org/browse/NH-1579

NH1579.patch is actually a patch for the unit tests, adding example
domain objects and mappings.  If you run those tests with the
unpatched 2.0.1 build, you'll see the issue.  If you apply the
OneToManyDiscriminatorFix.patch, the tests pass.

I was able to look into the code a bit more, and the issue seems to
stem from the forceDiscriminator flag on the
SingleTableEntityPersister, which is driven by the persistent class
having the IsForceDiscriminator value set, but I wasn't able to track
down the logic any further than that.

I think my example is pretty straight-forward, but if there are any
thoughts or questions I'd be happy to talk through it, maybe there's a
better way to do what I want.  In my application's domain model, the
reasons for splitting up the children by type makes even more sense
than my Cart / Fruit / Apple / Orange example, but regardless of that,
the way the error manifests itself in NHibernate (it loads an Orange
in the database as an instance of the Apple class) suggests to me that
my fix is valid.

Keep up the good work with the project,
Jon

On Nov 21, 5:14 am, "Fabio Maulo" <[EMAIL PROTECTED]> wrote:
> Did you have created a JIRA ?I don't know what need other committers,
> personally I need to take a look to mappings and a NUnit test case.
>
> On the air... you are mixing business stuff with persistence stuff.
> BTW before take any kind of decisions a NUnit failing test would be useful.
>
> 2008/11/20 Jon Stelly <[EMAIL PROTECTED]>
>
>
>
>
>
> > Hi guys,
>
> > I posted an issue I was seeing to nhusers because when i started I was
> > sure I was doing something stupid (which is still possible), but not
> > too long after posting there I found something in the
> > SingleTableEntityPersister that seems to be causing my issue.  I'm
> > using version 2.0.1 but the issue seems to have been around for a good
> > while.
>
> > The summary in my original post is tough to read, you guys will
> > probably find it easier to just look at the change I made.  To
> > summarize it a little better here, I've got a table per hierarchy
> > mapping strategy and a class with 2 one-to-many collections of
> > different types (all types are in this class hierarchy).  The
> > relationships are bidirectional parent/child type, but I'd like the
> > children split into these two collections instead of all being in one
> > big Children collection.  Without my patch, NHibernate wasn't
> > generating a WHERE clause based on discriminators when loading those
> > collections and it was actually causing it to hydrate a database
> > record of one type as an instance of another, corrupting the session's
> > cache.
>
> > It's this thread (
> >http://groups.google.com/group/nhusers/browse_thread/thread/d2baeaa5c...
> > ), I've gone through and made the change and run the NUnit tests in
> > NHibernate.Test.dll, the same tests succeed and fail with or without
> > my patch.  The queries generated with this patch seem more correct for
> > me, I've tested with one-to-many mappings of subclasses, with derived
> > subclasses, joined-subclasses, and standalone class mappings, all of
> > those scenarios seem to work.
>
> > I'm going to create a JIRA ticket but I was looking through the
> > history of SingleTableEntityPersister and this code hasn't been
> > changed in a good while, so I wanted to see if you guys had any input
> > first.
>
> > The patch would end up being this:
>
> > Index: SingleTableEntityPersister.cs
> > ===================================================================
> > --- SingleTableEntityPersister.cs       (revision 3917)
> > +++ SingleTableEntityPersister.cs       (working copy)
> > @@ -522,7 +522,7 @@
>
> >                public override string OneToManyFilterFragment(string
> > alias)
> >                {
> > -                       return forceDiscriminator ?
> > DiscriminatorFilterFragment(alias) :
> > string.Empty;
> > +                       return DiscriminatorFilterFragment(alias);
> >                }
>
> >                private string DiscriminatorFilterFragment(string
> > alias)
>
> > Thanks,
> > Jon
>
> --
> Fabio Maulo

Reply via email to