BeanFondi has an association with BeanFondiEU that has two subclasses: BeanfondiE and BeanFondiU.
They are mapped by Hibernate in followed way:
BEANFONDI:
<hibernate-mapping>
<class
name="BeanFondi"
table="FONDI"
>
<id
name="fnId"
type="java.lang.Integer"
column="FNID">
<generator class="assigned"/>
</id>
<property
name="fnCodice"
column="FNCODICE"
type="java.lang.Integer"
not-null="false"
length="2"
/>
<property
name="fnDescrizione"
column="FNDESCRIZIONE"
type="java.lang.String"
not-null="true"
length="50"
/>
<set name="fondiE" lazy="true" inverse="true" >
<key column="FNDFONDIID"/>
<one-to-many class="BeanFondiE"/>
</set>
<set name="fondiU" lazy="true" inverse="true" >
<key column="FNDFONDIID"/>
<one-to-many class=" BeanFondiU"/>
</set>
</class>
</hibernate-mapping>
BEANFONDIEU:
<hibernate-mapping>
<class
name="BeanFondiEU"
table="FONDID">
<id
name="fnEUId"
type="java.lang.Integer"
column="FNDID">
<generator class="sequence">
<param name ="sequence">GENFONDID</param>
</generator>
</id>
<discriminator
type="java.lang.String"
column="FNDTIPO"
not-null="true"
length="1"/>
<property
name="fnEUAnno"
type="java.lang.Integer"
column="FNDANNO"
not-null="true"
length="4"
/>
<many-to-one
name="beanFondi"
column="FNDFONDIID"
class=" BeanFondi"
cascade="none"
outer-join="true"
not-null="true" >
</many-to-one>
<subclass
name="BeanFondiE"
discriminator-value="E">
</subclass>
<subclass
name="BeanFondiU"
discriminator-value="U">
</subclass>
</class>
</hibernate-mapping>
When I retrive elements of the subclass beanFondiE from database the queries are the following:
select beanfondi0_.FNID as FNID0_, beanfondi0_.FNCODICE as FNCODICE8_0_, beanfondi0_.FNDESCRIZIONE as FNDESCRI3_8_0_, beanfondi0_
from FONDI beanfondi0_ where beanfondi0_.FNID=?
select fondie0_.FNDFONDIID as FNDFONDIID__, fondie0_.FNDID as FNDID__, fondie0_.FNDID as FNDID8_, fondie0_.FNDANNO as FNDANNO9_8_, fondie0_.FNDFONDIID as FNDFONDIID9_8_
from FONDID fondie0_ where fondie0_.FNDFONDIID=?
All records of table FONDID are retrived, also the elements of subclass beanfondiu. I don't have access to discriminator to filter only the elements of BeanFondiE or BeanFondiU from BeanFondi.
How can I resolve this problem?
Thank you.
|