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

Go To StackoverFlow.com

3

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=2.0.0.0, 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">
    <id>
      <generator class="identity" />
    </id>
    <discriminator column="Name" type="String" />
  </class>
  <subclass name="NhibernateTest.StringProperty, PromoNhibernateTest" lazy="false" extends="NhibernateTest.AbstractGenericProperty`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], PromoNhibernateTest" discriminator-value="string" />
</hibernate-mapping>

Please advise what is wrong with the mapping.

Thanks,

Ted.

2009-06-16 09:59
by NoName


0

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
Ads