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?