My mapping file is as below:
<class name="MainClass" table="MAIN_CLASS">
<id name="id" type="long" unsaved-value="0">
<generator class="native"/>
</id>
<discriminator column="class_type" type="string"/>
...
<property name="className" column="class_name" not-null="true" type="yes_no"/>
<property name="classType" column="class_type" not-null="true" type="yes_no"/>
<subclass name="CurrentSubClass" discriminator-value="CURRENT">
</subclass>
<subclass name="FutureSubClass" discriminator-value="FUTURE">
<property name="date" column="date" type="date"/>
</subclass>
</class>
I followed one of the examples somewhere but i cant seem to retrieve the correct subclass
i can save correctly in the sense that the discriminator value is set correctly but when i try to retrieve the specified subclasses i get both CurrentSubClass and FutureSubClass
Example, i mananged to store correctly 2x CurrentSubClass objects and 2xFutureSubClass objects but when i do a retrieval like this:
List subclassList = sess.createCriteria(SomeOtherClass.class)
.add( Expression.eq("id", new Long(1) ))
.setFetchMode("FutureSubClass", FetchMode.EAGER)
.list();
The number of results is 4 instead of just 2. i tried the same thing with hql and still get the same results so what gives? if you need more information please let me know. Thanks!!!
|