You were absolutely correct, and I believe that I have the problem
fixed.
The problem was actually in the setup of my SessionFactory.
This is correct and actually works:
Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2000
.ConnectionString(c =>
c.FromConnectionStringWithKey(""))
.ShowSql())
.Mappings(m =>
m.FluentMappings.AddFromAssembly(Assembly.Load("Peotsc.DataAccess")))
.Mappings(m =>
m.FluentMappings.ExportTo("mappings"))
.BuildSessionFactory();
Not being too familiar with Reflection and NHibernate, I was doing
this:
Fluently.Configure()
.Database
(MsSqlConfiguration.MsSql2000
.ConnectionString(c =>
c.FromConnectionStringWithKey(""))
.ShowSql())
.Cache(c => c
.UseQueryCache()
.ProviderClass<HashtableCacheProvider>
())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<MenuItemMap>())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<MenuItemTypeMap>())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<DivisionMap>())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<FunctionalAreaMap>())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<GovernmentBuildingMap>())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<PhoneMap>())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<PkiCertificateMap>())
.BuildSessionFactory();
I hit upon this as the answer because I accidentally put a breakpoint
at one of the HasManyToMany definitions in UserMap and noticed that it
was being hit several times over and didn't think that was correct. I
checked your test application and, sure enough, you only hit the
definition once. I determined that I needed to load up the assembly
that defined the mappings and pass *that* into AddFromAssemblyOf.
Like magic, everything seems to be working correctly now.
I really appreciate all of your help, and for not giving up. If you
have an Amazon Wishlist or something, please let me know, it's the
least I can do.
-Robert Eberhart
On Jan 16, 9:46 am, Paul Batum <[email protected]> wrote:
> Hi Robert,
>
> The self referencing nature is not the issue. If you're prepared to spend
> any more time on it, I've uploaded a very basic example project. Perhaps it
> will help you
> troubleshoot:http://github.com/paulbatum/Fluent-NH-Test-Bed/tree/self-referencing-...
>
> <http://github.com/paulbatum/Fluent-NH-Test-Bed/tree/self-referencing-...>There
> is a download source link if you just want a zip and don't want to fool
> around with git.
>
> Paul.
>
> On Sat, Jan 16, 2010 at 1:44 AM, TheNephalim <[email protected]>wrote:
>
> > Still a "No go."
>
> > Theoretically, it should work, but I think that the issue is that the
> > items that are composing the many-to-many relationship are of the same
> > type. If, for example, I had a separate entity called Sponsor with
> > its own data and linked the Sponsors to the Users in the UserSponsor
> > table, I have almost no doubt in my mind that what you are proposing
> > would work. However, both keys in the UserSponsor table point back to
> > the same table and I think that that is what's throwing this whole
> > thing off.
>
> > According to Mr. Gregory in some of his blog posts (at least I think
> > that it was him) and the documentation for NHibernate, true many-to-
> > many relationships are supposed to be rare and can actually be broken
> > down to a many-to-one - one-to-many scenario.
>
> > I wish that the many-to-many scenario would have worked because it
> > would have reduced the size of the objects being pulled back.
>
> > Again, I really do appreciate you taking the time to assist me in this
> > endeavor; it has been very educational.
>
> > -Robert Eberhart
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<fluent-nhibernate%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/fluent-nhibernate?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" 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/fluent-nhibernate?hl=en.