NHibernate: These classes referenced by 'extends' were not found

Go To StackoverFlow.com


I have a simple example; a concrete class that inherits an abstract generic class that implements an interface.

ie. StringProperty -> AbstractProperty<T> -> IProperty

I get the following error...

NHibernate.MappingException: These classes referenced by 'extends' were not found:
NhibernateTest.AbstractGenericProperty`1[[System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089]], PromoNhibernateTest
   at NHibernate.Cfg.MappingsQueue.CheckNoUnavailableEntries()
   at NHibernate.Cfg.Configuration.SecondPassCompile()
   at NHibernate.Cfg.Configuration.BuildSessionFactory()

I use NHibernate attributes which produce the following mapping...

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="NhibernateTest.AbstractGenericProperty`1, PromoNhibernateTest" lazy="false" table="Properties">
      <generator class="identity" />
    <discriminator column="Name" type="String" />
  <subclass name="NhibernateTest.StringProperty, PromoNhibernateTest" lazy="false" extends="NhibernateTest.AbstractGenericProperty`1[[System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089]], PromoNhibernateTest" discriminator-value="string" />

Please advise what is wrong with the mapping.



2009-06-16 09:59
by NoName


The problem is that it is not possible to map AbstractProperty.

You cannot map open generic types, even if you also create subclass mappings that define the generic type.

I don't quite know why NHibernate only starts complaining when it gets to the subclass mapping, but I'm pretty sure that the problem is with the AbstractProperty mapping, not the subclass.

2012-09-24 07:59
by cbp