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: Proxied object refusing to initialize
PostPosted: Mon Mar 06, 2006 12:39 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I have a simple bidirectional many-to-one: MeterPointImpl contains many InstallationImpls. When I load an InstallationImpl by primary key, the MeterPointImpl it's giving me is CGlib proxied, but accessing most of the members returns null, even though the DB row has non-null values. The output doesn't show any hibernate activity when I access installation.getMeterPoint().get<anything>(). The only field that gets a value is Name, which coincidentally is the only field that was accessed the previous time this object was loaded (in the previous session: this is a webapp using OpenSessionInView). Evicting/Hibernate.initializing any and all objects makes no difference. Loading the objects via HQL doesn't help. When I load the MeterPointImpl using the Name field (as it's the only one that I know is valid), then the returned MeterPointImpl is not proxied and is fully correct.

Arg!

The relevant parts of the mapping:
Code:
  <class name="InstallationImpl" table="Installation">
    ...
    <many-to-one name="MeterPoint" column="MeterPointID"
      class="MeterPointImpl" update="false">
    </many-to-one>
    ...
  </class>

  <class name="MeterPointImpl" table="MeterPoint">
    ...
    <set name="Installations" inverse="true" cascade="all" order-by="StartDateTime">
      <key column="MeterPointID"/>
      <one-to-many class="InstallationImpl"/>
    </set>
  </class>
Can anyone figure out what I'm doing wrong? There are a few strangenesses in the mapping, mostly due to incomplete changes made in the distant past (I'm looking at inverse="true" cascade="all" with some suspicion); are any of those to blame?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 5:57 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Out of desperation I changed the many-to-one in InstallationImpl to fetch="join" (from the default, fetch="select"), and it all works now. Looks like a bug? Anyone else noticed anything like this?


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.