N-to-N associations can be tricky. Would list your mapping files ?

On Fri, Jun 5, 2009 at 10:32 AM, Chris <[email protected]> wrote:

>
> Not sure what WCF is?
>
> As for tests to recreate ... I don't have a small testbed at this
> point. In general, NHibernate has been working for us, and continues
> to do so, it's just this one strange situation. As previously
> mentioned if I query for a user object and add a group to it, then
> save/commit the user, it works fine. If I query for a group object and
> then add a user to it, then save/commit the group, that's when this
> occurs. In both cases, the queried object correctly populates the list
> of users/groups so this seems to imply that the mapping is setup
> correctly. I have seen similar errors when the mapping is incorrect,
> but I've never seen it complain about not being able to locate one of
> its own internal classes. Was hoping someone else has seen it before
> and had a resolution.
>
> On Jun 5, 8:31 am, Fabio Maulo <[email protected]> wrote:
> > Is there any other part of the story you want say us ?WCF ?
> > Tests to recreate the exception ?
> >
> > 2009/6/4 Chris <[email protected]>
> >
> >
> >
> >
> >
> > > I have a weird exception that’s being thrown from NHibernate where it
> > > seems to not be able to lookup one of its own classes. The background
> > > is that I have 2 objects Users & Groups mapped to corresponding
> > > tables. On each, there’s a many-to-many bag that uses another table to
> > > maintain relationship. In each class, the corresponding bag is mapped
> > > to a System.Collections.IList.  The problem is that if I add a user to
> > > a group, the unknown entity class exception (see subject) is thrown.
> > > However, if I add a group to a user, all works as expected.
> > > Additionally, I can remove a user from a group w/o error. It’s only
> > > upon addition that it crops up. Most of the knowledge base I’ve seen
> > > around this usually is a result of mapping incorrectly, but I’m pretty
> > > sure this mapping is setup ok. Any help is appreciated.
> >
> > > Exception:
> > > [04/Jun/2009:15:34:38.187] (8   ) ERROR - could not synchronize
> > > database state with session
> > > NHibernate.MappingException: Unknown entity class:
> > > NHibernate.Collection.PersistentBag
> > >   at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(Type
> > > theClass)
> > >   at NHibernate.Impl.SessionImpl.GetClassPersister(Type theClass)
> > >   at NHibernate.Impl.SessionImpl.GetEntityPersister(Object obj)
> > >   at NHibernate.Impl.SessionImpl.GetEntityIdentifierIfNotUnsaved
> > > (Object obj)
> > >   at NHibernate.Type.EntityType.GetIdentifier(Object value,
> > > ISessionImplementor session)
> > >   at NHibernate.Type.ManyToOneType.NullSafeSet(IDbCommand st, Object
> > > value, Int32 index, Boolean[] settable, ISessionImplementor session)
> > >   at
> > >
> NHibernate.Persister.Collection.AbstractCollectionPersister.WriteElement
> > > (IDbCommand st, Object elt, Int32 i, ISessionImplementor session)
> > >   at
> > > NHibernate.Persister.Collection.AbstractCollectionPersister.Recreate
> > > (IPersistentCollection collection, Object id, ISessionImplementor
> > > session)
> > >   at NHibernate.Impl.ScheduledCollectionUpdate.Execute()
> > >   at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
> > >   at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
> > >   at NHibernate.Impl.SessionImpl.Execute()
> >
> > > XML mapping:
> > >  <class name="MiCo.MiForms.Server.MFSUser, DataCore"
> > > table="mfs_user">
> > >    <id name="ID" column="id_mfs_user" type="Int32">
> > >      <generator class="native" />
> > >    </id>
> > >    <bag name="Groups" table="user_to_group">
> > >      <key column="id_mfs_user"/>
> > >      <many-to-many class="MiCo.MiForms.Server.MFSGroup, DataCore"
> > > column="id_mfs_group" />
> > >    </bag>
> > >  </class>
> >
> > >  <class name="MiCo.MiForms.Server.MFSGroup, DataCore"
> > > table="mfs_group">
> > >    <id name="ID" column="id_mfs_group" type="Int32">
> > >      <generator class="native" />
> > >    </id>
> > >    <bag name="Users" table="user_to_group">
> > >      <key column="id_mfs_group"/>
> > >      <many-to-many class="MiCo.MiForms.Server.MFSGroup, DataCore"
> > > column="id_mfs_group"  />
> > >    </bag>
> > >  </class>
> >
> > --
> > Fabio Maulo
> >
>


-- 
Humberto C Marchezi
---------------------------------------------------------
Master in Electrical Engineering - Automation
Software Consultant and Developer
at the Town Hall of Vitória

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