-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Proxy problem: abstract class + abstract method. Bug or not?
PostPosted: Fri Jan 06, 2006 12:36 pm 
Beginner
Beginner

Joined: Mon Dec 19, 2005 4:13 am
Posts: 27
Location: Prague, Czech Republic
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 07, 2006 7:30 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
This is a bug in DynamicProxy library, if I remember correctly. It doesn't allow a proxied class to have an abstract method. Until this is fixed, there's nothing NHibernate can do about it.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 08, 2006 8:25 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Does anyone know whether this has been raised with the Castle team, or even whether it *can* be fixed?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 08, 2006 9:41 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, they know about it. I just sent a message to their mailing list to ask about their plans.


Top
 Profile  
 
 Post subject: Any advance?
PostPosted: Wed Jan 25, 2006 4:16 am 
Beginner
Beginner

Joined: Mon Dec 19, 2005 4:13 am
Posts: 27
Location: Prague, Czech Republic
Sergey,

did they send some response? How it looks like?

Many thanks.
David


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 25, 2006 5:10 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's fixed in 1.0.2.


Top
 Profile  
 
 Post subject: Many thanks.
PostPosted: Wed Jan 25, 2006 5:24 am 
Beginner
Beginner

Joined: Mon Dec 19, 2005 4:13 am
Posts: 27
Location: Prague, Czech Republic
It really work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.