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.  [ 1 post ] 
Author Message
 Post subject: Lazy-loading objects mapped for direct field access
PostPosted: Mon Jul 07, 2008 2:32 pm 
Newbie

Joined: Mon Jul 07, 2008 1:29 pm
Posts: 1
1.2.0
I've observed the following behavior while attempting to lazy-load an object that contains fields mapped using access="field.camelcase". I would appreciate it if someone could confirm that it is not a result of improper mapping and/or class creation.

Assuming this simplified mapping:

Code:

<class name="Foo">
      <many-to-one name="Field" class="Bar" access="field.camelcase" />
  </class>

The Foo class should look like this:
Code:
  public class Foo
  {
    private Bar field;
   
    public Bar Field
    {
      get {return field;}
      set {field = value;}
    }
  }

If another class lazily initializes an instance of Foo, a proxy extending Foo is generated. Even though the property is not marked as virtual, based on my understading of the access="field.camelcase" attribute, this should be irrelevant to retrieving or setting the value of field. Yet, after stepping through this precise scenario, any attempts to access field always returns null. Inspecting the generated proxy via Visual Studio's debugger reveals that field in the base class is, in fact, null. This same behavior occurs if field is set to protected as opposed to private.

Now if I leave the mapping untouched but make the property virtual, accessing field via the property works but field in the generated proxy's base class is still null.

Is this behavior expected? If not, at what point does my understanding of direct field access break down?


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

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.