2.1.09

Joined-Subclass exception

NHibernate.MappingException: 'extends' attribute is not found.

at NHibernate.Cfg.XmlHbmBinding.ClassBinder.GetSuperclass(XmlNode subnode)
at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddJoinedSubclasses(XmlNode parentNode)
at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(XmlNode node)
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)

NHibernate.MappingException: Could not compile the mapping document: Zainco.YCW.Components.Mappings.Member.hbm.xml

at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
at NHibernate.Cfg.Configuration.ProcessMappingsQueue()
at NHibernate.Cfg.Configuration.AddDocumentThroughQueue(NamedXmlDocument document)
at NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader, String name)
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
at NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly)
at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)
at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName)
at NHibernate.Cfg.Configuration.DoConfigure(IHibernateConfiguration hc)
at NHibernate.Cfg.Configuration.Configure()
at Zainco.YCW.Components.Utils.NHibernateHelper.get_Session() in
NHibernateHelper.cs: line 13
at Zainco.YCW.Tests.MemberTest.AddMember() in MemberTest.cs: line 70

If you get this exception then you have probably defined your joined-subclass outside the parent class, which is probably not a good idea if you are aiming to have highly cohesive and modular mapping files. The problem is easily resolved by either adding an extends attribute to the joined-subclass element

<joined-subclass name="KeyLeaderNationalTeamTasks"  table="KeyLeaderNationalTeamTasks" extends="Task">

or nesting the joined-subclass in the class definition.

No comments: