Hibernate version:
2.1.8
Problem:
I have a subclass GP_GPAktionZuordnungPO mapped with 'Table-per-class-hierarchy'. GeschaeftspartnerPO should have a set with GP_GPAktionZuordnungPOs. But with this mappings discriminating doesen't work, following sql query was generated:
select gpaktionen0_.BEZUG_ID as BEZUG_ID__, gpaktionen0_.AKTION_ZUORD_ID as AKTION_Z1___, gpaktionen0_.AKTION_ZUORD_ID as AKTION_Z1_0_, gpaktionen0_.BEZUG_ID as BEZUG_ID0_, gpaktionen0_.CODE as CODE0_, gpaktionen0_.CODE_ID as CODE_ID0_, gpaktionen0_.GP_AKTION_ID as GP_AKTIO4_0_ from AKTION_ZUORD gpaktionen0_ where gpaktionen0_.BEZUG_ID=?
Why?
Mapping documents:
BASECLASS
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.carano.cbf.partner.po.AbstractGPAktionZuordnungPO" table ="AKTION_ZUORD"
proxy="com.carano.cbf.partner.po.AbstractGPAktionZuordnungPO">
<!--<cache usage="read-write"/>-->
<id column="AKTION_ZUORD_ID" name="ID" unsaved-value="any">
<generator
class="com.carano.framework.abo.persistence.hibernate.HibernateIDGenerator"/>
</id>
<!--Discriminator AktionBezug-->
<discriminator>
<column name="CODE" not-null="true"/>
</discriminator>
</class>
</hibernate-mapping>
SUBCLASS:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<subclass name="com.carano.cbf.partner.po.GP_GPAktionZuordnungPO"
extends="com.carano.cbf.partner.po.AbstractGPAktionZuordnungPO"
discriminator-value="G_PARTNER"
proxy="com.carano.cbf.partner.po.GP_GPAktionZuordnungPO">
<!-- Is DepBO, list owners below -->
<!-- owner -->
<many-to-one name="geschaeftspartner"
class="com.carano.cbf.partner.po.GeschaeftspartnerPO"
column="BEZUG_ID" not-null="true"/>
<!-- End of owners -->
</subclass>
</hibernate-mapping>
Collection is mapped here:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.carano.cbf.partner.po.GeschaeftspartnerPO" table ="G_PARTNER" proxy="com.carano.cbf.partner.po.GeschaeftspartnerPO">
<!--<cache usage="read-write"/>-->
<id name="ID">
<column name="G_PARTNER_ID" sql-type="int"/>
<generator class="com.carano.framework.abo.persistence.hibernate.HibernateIDGenerator"/>
</id>
<set name="gpAktionsZuordnungen" table="AKTION_ZUORD" cascade="all-delete-orphan" lazy="true" inverse="true">
<key>
<column name="BEZUG_ID" sql-type="int"/>
</key>
<one-to-many class="com.carano.cbf.partner.po.GP_GPAktionZuordnungPO"/>
</set>
</class>
</hibernate-mapping>
|