I believe this issue was fixed in the recently-released NH 3.2, please
give that version a try if you're on an earlier version.  If you're
still seeing this problem on 3.2, please file a bug here:
https://nhibernate.jira.com/ and note that it's probably related to
this issue: https://nhibernate.jira.com/browse/NH-1747.

Good luck!

Anne

On Thu, Oct 27, 2011 at 12:58 PM, Trinition <[email protected]> wrote:
> I have a hierarchial set of parent Foos and child Bars, both of which
> extend from the same base type.  In my code, I invoke
> "myBase.Children":
>
>    foreach (BaseType base in myBase.Children) // <-- this line throws
> the error
>    {
>        Activate(base, owner);
>    }
>
> This code gets an error.  The error indicates that the NHibernate 3.1
> generated SQL is wrong (yes, BaseID does appear twice in a row!):
>
>    SELECT BaseType.FooID,
>       BaseType.BaseID,
>       BaseType.BaseID,
>       BaseType.Name,
>       Bar.FooID,
>    FROM dbo.Bases BaseType
>       inner join dbo.Bars Bar
>         on BaseType.BaseID = Bar.BarID
>    WHERE BaseType.FooID = 136 /* @p0 */
>
> But "FooID" doesn't exist in BaseType.  It *does* exist in Bars.  Why
> does NHibernate expect the column on the base class' table instead of
> the parent classes table?  For what its worth, "Base" is abstract.
>
> Here's my FluentNHibernate mapping:
>
>    public class FooMap : SubclassMap<Foo>
>    {
>        public FooMap()
>        {
>            DiscriminatorValue(3);
>            Join("Foos", m =>
>            {
>                m.KeyColumn("FooID");
>                ...
>                m.HasMany(x => x.Bars)
>                    .KeyColumn("FooID")
>                    .AsSet()
>                    .Cascade.All()
>                    .LazyLoad();
>                ...
>            });
>        }
>    }
>
> I've reproduced this in a tinym sloppy integration test where I do
> "myBase.Children.Count()" instead, but it fails with the same error.
>
> --
> 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.

Reply via email to