-->
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.  [ 2 posts ] 
Author Message
 Post subject: Proxy properties don't call base properties
PostPosted: Thu Feb 16, 2006 11:39 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Hibernate version: 1.0.2

My entities are mapped as lazy and use field access. When an entity is proxied, after the proxy is initialized, the fields in my entity's class that back its properties are still null! Checking with the Visual Studio debugger, my property getters & setters are never entered. Apparently proxies keep their own storage!

This appears to be a MAJOR problem. We have logic (mostly in the setters, but even some in getters) that must execute. Shouldn't the proxies simply lazyload when the proxy is unitialized, and then just call the base getter/setter? I.e. I expected proxy properties to be nothing more than this:

Code:
public override SomeType SomeProperty
{
    get
    {
        if (!NHibernateUtil.IsInitialized(this)) NHibernateUtil.Initialize(this);
        return base.SomeProperty;
    }
    set
    {
        if (!NHibernateUtil.IsInitialized(this)) NHibernateUtil.Initialize(this);
        base.SomeProperty = value;
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 6:52 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
When a proxy is loaded, NHibernate actually creates a second object of the type (or a descendant type, depending on the actual type of the object in the database), and redirects all calls on a proxy to it. This may cause the effects you are seeing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.