Hello,
I have a newbee question. Is it allowed to use lazy loading on abstract classes with abstract methods? I have abstract class Subject and some concrete class which derive from it. Mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="field.pascalcase-m-underscore" assembly="TEST.Business" namespace="TEST.Business">
<class name="TEST.Business.Subjects.Subject" table="Subject" lazy="false">
<id name="Id" type="Int32" column="id_Subject" unsaved-value="0">
<generator class="native" />
</id>
<property name="CreatedOn" type="DateTime" not-null="true" />
<many-to-one name="Rating" class="TEST.Business.Subjects.SubjectRating" column="id_Rating" not-null="true" />
<property name="IsActive" type="Boolean" not-null="true" />
<property name="Keywords" type="String" />
</class>
</hibernate-mapping>
I can do everything if the mapping is like this, but when i change "lazy" on the "class" to "true", it works fine only if I do not have any abstract method on the class. If I have one, the proxy cannot be created. The exception bellow is from Session.Load method:
Code:
NHibernate.HibernateException was unhandled
Message="Creating a proxy instance failed"
Source="NHibernate"
StackTrace:
at NHibernate.Proxy.CastleProxyFactory.GetProxy(Object id, ISessionImplementor session) in C:\Documents and Settings\sousek\My Documents\Visual Studio 2005\Projects\Sprinx.Framework\NHibernate\Proxy\CastleProxyFactory.cs:line 71
at NHibernate.Persister.AbstractEntityPersister.CreateProxy(Object id, ISessionImplementor session) in C:\Documents and Settings\sousek\My Documents\Visual Studio 2005\Projects\Sprinx.Framework\NHibernate\Persister\AbstractEntityPersister.cs:line 1494
at NHibernate.Impl.SessionImpl.DoLoadByClass(Type clazz, Object id, Boolean checkDeleted, Boolean allowProxyCreation) in C:\Documents and Settings\sousek\My Documents\Visual Studio 2005\Projects\Sprinx.Framework\NHibernate\Impl\SessionImpl.cs:line 2399
at NHibernate.Impl.SessionImpl.Load(Type clazz, Object id) in C:\Documents and Settings\sousek\My Documents\Visual Studio 2005\Projects\Sprinx.Framework\NHibernate\Impl\SessionImpl.cs:line 2265
at SF.BusinessSupport.BusinessEntityFactory`1.FindById(Int32 id, FetchMethod method) in C:\Documents and Settings\sousek\My Documents\Visual Studio 2005\Projects\Sprinx.Framework\SF.BusinessSupport\BusinessEntityFactory.cs:line 29
at SF.BusinessSupport.BusinessEntityFactory`1.FindById(Int32 id) in C:\Documents and Settings\sousek\My Documents\Visual Studio 2005\Projects\Sprinx.Framework\SF.BusinessSupport\BusinessEntityFactory.cs:line 38
at TEST.Console.Program.Main(String[] args) in C:\Documents and Settings\sousek\My Documents\Visual Studio 2005\Projects\Sprinx.Framework\TEST.Console\Program.cs:line 25
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Inner exception: "Argument 'baseClass' must be a concrete class"
Please can someone tell me if I am doing something wrong or is it a bug or is it a feature with which I must live? Is there any workaround?
Many thanks.
David