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