I am new to NHibernate and trying to map a domain model that has a bit of inheritance, etc. (see this question for full details of my model, starting a new question, as this is another mistake)
There are some abstract methods in my base class that each class below should execute. This seems to be causing problems with NHibernate, although I implemented the class in my domain model, the NHibernates proxy class seems to be having problems.
One of these methods is SetRequired, which is invalid in my Question class, and I damaged it everywhere, but when I try to check my mappings, I get this error:
PmqccFormIntegrationTests.TestJobVelocityQuestionPersists : FailedNHibernate.HibernateException : Creating a proxy instance failed
----> System.TypeLoadException : Method 'SetRequired' in type 'QuestionProxy' from assembly 'QuestionProxyAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at NHibernate.ByteCode.LinFu.ProxyFactory.GetProxy(Object id, ISessionImplementor session)
at NHibernate.Tuple.Entity.AbstractEntityTuplizer.CreateProxy(Object id, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.CreateProxy(Object id, ISessionImplementor session)
at NHibernate.Event.Default.DefaultLoadEventListener.CreateProxyIfNecessary(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options, IPersistenceContext persistenceContext)
at NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)
at NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)
at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)
at NHibernate.Impl.SessionImpl.Load(String entityName, Object id)
at NHibernate.Impl.SessionImpl.Load(Type entityClass, Object id)
at PmqccDomain.DataAccess.NHibernate.AbstractNHibernateDao`2.GetById(IdT id, Boolean shouldLock) in AbstractNHibernateDao.cs: line 31
at PMQCC_IntegrationTests.PmqccFormIntegrationTests.TestJobVelocityQuestionPersists() in PmqccFormIntegrationTests.cs: line 92
--TypeLoadException
at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
at System.Reflection.Emit.TypeBuilder.CreateType()
at LinFu.DynamicProxy.ProxyFactory.CreateUncachedProxyType(Type[] baseInterfaces, Type baseType)
at LinFu.DynamicProxy.ProxyFactory.CreateProxyType(Type baseType, Type[] baseInterfaces)
at LinFu.DynamicProxy.ProxyFactory.CreateProxy(Type instanceType, IInterceptor interceptor, Type[] baseInterfaces)
at NHibernate.ByteCode.LinFu.ProxyFactory.GetProxy(Object id, ISessionImplementor session)
'abstract = "true" lazy = "false", . ?
EDIT:
<class name ="PmqccDomain.DomainObjects.Question,PmqccDomain" abstract="true" table="Questions">
<id column="QuestionId" name="Id" type="Int32" unsaved-value="-1">
<generator class="native"></generator>
</id>
<discriminator column="QuestionType" type="String" />
<property name="Explanation"/>
<many-to-one name="PmqccForm" class="PmqccDomain.DomainObjects.PmqccForm" column="PmqccFormId" />
<subclass name="PmqccDomain.DomainObjects.NormalQuestion,PmqccDomain" abstract="true" lazy="false">
<property name="InputtedAnswer"/>
<subclass name="PmqccDomain.DomainObjects.AsConsQuestion,PmqccDomain" lazy="false" />
<subclass name="PmqccDomain.DomainObjects.PiAlertQuestion,PmqccDomain" lazy="false">
<many-to-one name="ResponsibleStaffMember" class="PmqccDomain.DomainObjects.StaffMember" column="ResponsibleStaffId" />
</subclass>
</subclass>
<subclass name="PmqccDomain.DomainObjects.JobVelocityQuestion,PmqccDomain" lazy="false">
<property name="InputtedAnswer"/>
</subclass>
</class>