Hibernate version: 3.05
Interesting scenario occuring for me here. I have mapped my inheritence tree the following way:
A root class
B inherits from A
C inherits from B
D inherits from B
Here is my mapping doc (Note: object B is not mapped because it does not have any new functionality than object A):
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="package.A" table="A" discriminator-value="0" >
<cache usage="read-only" />
<id name="number" type="java.lang.Integer" unsaved-value="null">
<column name="COLUMN_1"/>
</id>
<discriminator formula="CASE WHEN VALUE_1 IN (5,17) THEN 1 ELSE CASE WHEN VALUE_1 IN (6,18) THEN 2 ELSE 0 END END" type="string" />
<subclass name="package.C" discriminator-value="1"></subclass>
<subclass name="package.D" discriminator-value="2"></subclass>
</class>
</hibernate-mapping>
99.9% of the time when I request a list of C objects using the code below, I get a list of physical C objects; but 0.1% of the time I get, for example: 3 C objects and 1 C$$EnhancerByCGLIB$$... proxy object. Of course I cannot map the object or reference it as a C object or I get an ClassCastException.
Code:
createQuery("FROM A Type1, A Type2 WHERE Type2.value_2 = Type1.value_2 AND Type2.value_1 IN (5,17) AND Type1.value_3 = ?").setInteger(0, object.getNumber()).list();
Any idea why for 0.1% of the time Hibernate does not map the object directly?
Thanks is advance...
|