Hibernate version:
Was 3.0.5, is now 3.2.1. Since upgrading, objects loaded via many-to-one associations cannot be deproxied. I'm thinking it's because lazy="true" has been replaced, but I've tried all three values of that attribute, and it affects them all.
Loading AbstractLoggers directly works fine, I get ETypeLoggers and MTypeLoggers as appropriate. Via many-to-ones, I get AbstractLoggers (the abstract base class), and no amount of property-accessing, Hibernate.initialize()ing, or anything else that I can think of, works. My next step is to eliminate polymorphism, and put all properties into a non-abstract class. Not ideal, so I'm hoping someone spots my error.
Mapping documents:
The big weirdness here is that the discriminator column isn't in the mapped table, it's in an associated type table. Loggers have LoggerTypes, LoggerTypes have an AMRTypeID column, and the two values of that column determine the class of the Logger.
Code:
<class name="LoggerType" table="MeterType" mutable="false">
...
<property name="AMRType" column="AMRTypeID">
<type name="IntValuedEnum">
<param name="enum">
...AMRType
</param>
</type>
</property>
...
</class>
<class name="AbstractLogger" table="Logger" mutable="true" abstract="true"
discriminator-value="null">
...
<discriminator type="character" insert="false"
formula="
case when LoggerTypeID in
(select mt.MeterTypeID from MeterType mt
where mt.AMRTypeID = '1')
then 'E'
else 'M'
end"/>
<many-to-one name="Type" class="LoggerType"
unique="false" not-null="true"
column="LoggerTypeID"/>
...
<subclass name="ETypeLogger" discriminator-value="E"/>
<subclass name="MTypeLogger" discriminator-value="M">
<property name="MemorySize" column="MemorySize" type="integer"/>
...
</subclass>
</class>
Any many-to-one from any other class to AbstractLogger exhibits the symptoms.