Mapping of superclass X:
<?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 column="G_PARTNER_ID" name="ID">
<generator class="dbfps.fahrzeug.persistence.DBFPSIDGenerator"/>
</id>
<!-- RefBO konzern -->
<property name="konzern" column="KONZERN_ID"/>
<!-- RefBO mandant -->
<property name="mandant" column="MANDANTEN_NR_ID"/>
<!-- RefBO anrede -->
<property name="anrede" column="ANREDE_ID"/>
<!-- DepBOList -->
<set name="bankverbindung" table="BANKVERBINDUNG" cascade="all" lazy="true" inverse="true">
<key column="G_PARTNER_ID"/>
<one-to-many class="com.carano.cbf.partner.po.BankverbindungPO"/>
</set>
<!-- RefBO staat -->
<property name="staat" column="STAAT_ID"/>
<!-- RefBO rechtsform -->
<property name="rechtsform" column="RECHTSFORM_ID"/>
<!-- RefBO status -->
<property name="status" column="GP_STATUS_ID"/>
<!-- RefBO rolle -->
<property name="rolle" column="GP_ROLLE_ID"/>
<!-- RefBO region -->
<property name="region" column="REGION_ID"/>
<!-- RefBO wirtBez -->
<property name="wirtBez" column="GP_WIRT_BEZ_ID"/>
<!-- RefBO waehrung -->
<property name="waehrung" column="WAEHRUNG_ID"/>
<!-- RefBO steuersatz -->
<property name="steuersatz" column="STEUERSATZ_ID"/>
<!-- RefBOList -->
<set name="geschaeftspartnerGruppe" table="GP_GRUPPEN" lazy="true">
<key column="G_PARTNER_ID"/>
<many-to-many column="GP_GRUPPEN_DEF_ID" class="com.carano.cbf.partner.po.GeschaeftspartnerGruppePO"/>
</set>
<!-- RefBOList -->
<set name="branche" table="GP_BRANCHE" lazy="true">
<key column="G_PARTNER_ID"/>
<many-to-many column="BRANCHE_ID" class="com.carano.cbf.partner.po.BranchePO"/>
</set>
<property name="name" column="NAME"/>
<property name="name2" column="NAME2"/>
<property name="abteilung" column="ABTEILUNG"/>
<property name="kurzname" column="KURZNAME"/>
<property name="debitorenNr" column="DEBITOREN_NR"/>
<property name="kreditorenNr" column="KREDITOREN_NR"/>
<property name="kundenNr" column="KUNDEN_NR"/>
<property name="strasse" column="STRASSE"/>
<property name="plz" column="PLZ"/>
<property name="ort" column="ORT"/>
<property name="hausNr" column="HAUSNUMMER"/>
<property name="telefonNr" column="TELEFON_NR"/>
<property name="telefonNr2" column="TELEFON_NR2"/>
<property name="faxNr" column="FAX_NR"/>
<property name="email" column="E_MAIL"/>
<property name="postfach" column="POSTFACH"/>
<property name="plzPostfach" column="PLZ_POSTFACH"/>
<property name="plzort" column="PLZ_ORT"/>
<property name="kennNr" column="KENN_NR"/>
<property name="versichNr" column="VERSICH_NR"/>
<property name="bemerkung" column="BEMERKUNG"/>
<!-- RefBOList (which should be a DepBOList -->
<set name="gpAktionen" table="GPAKTION" cascade="all" lazy="true" inverse="true">
<key column="G_PARTNER_ID"/>
<one-to-many class="com.carano.cbf.angebot.po.GPAktionPO"/>
</set>
<!-- RefBO adresse -->
<property name="adresse" column="ADRESSE_ID"/>
<!-- DepBOList -->
<set name="zusatzadressen" table="ZUSATZADRESSE" cascade="all" lazy="true" inverse="true">
<key column="G_PARTNER_ID"/>
<one-to-many class="com.carano.cbf.partner.po.ZusatzAdressePO"/>
</set>
<!-- RefBO verkaufsleiter -->
<property name="verkaufsleiter" column="VERKAUFSLEITER_ID"/>
<!-- RefBO kundenbetreuer -->
<property name="kundenbetreuer" column="KUNDENBETREUER_ID"/>
<!-- RefBO betreuer -->
<property name="betreuer" column="MITARBEITER_ID"/>
<!-- RefBOList -->
<set name="sonstKommentar" table="GP_KOMMENTAR" lazy="true">
<key column="G_PARTNER_ID"/>
<many-to-many column="SONST_KOMMENT_ID" class="com.carano.general.po.SonstKommentarPO"/>
</set>
<!-- Log timestamps/ ids -->
<property name="IDMitarbeiterInsert" column="MITARB_ID_INS" not-null="false" unique="false" />
<property name="IDMitarbeiterUpdate" column="MITARB_ID_UPD" not-null="false" unique="false" />
<property name="TSInsert" column="TS_INSERT" not-null="false" unique="false" />
<property name="TSUpdate" column="TS_UPDATE" not-null="false" unique="false" />
</class>
</hibernate-mapping>
Mapping of subclass: Y
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<joined-subclass name="com.carano.cbf.partner.po.FPSGeschaeftspartnerPO"
extends="com.carano.cbf.partner.po.GeschaeftspartnerPO"
table="AV_G_PARTNER"
proxy="com.carano.cbf.partner.po.FPSGeschaeftspartnerPO">
<key column="G_PARTNER_ID"/>
<property name="bahnstelle" column="BAHNSTELLE"/>
<property name="kostenstelle" column="KOSTENSTELLE"/>
<!-- Log timestamps/ ids -->
<property name="IDMitarbeiterInsert" column="MITARB_ID_INS" not-null="false"
unique="false" />
<property name="IDMitarbeiterUpdate" column="MITARB_ID_UPD" not-null="false"
unique="false" />
<property name="TSInsert" column="TS_INSERT" not-null="false" unique="false"
/>
<property name="TSUpdate" column="TS_UPDATE" not-null="false" unique="false"
/>
</joined-subclass>
</hibernate-mapping>
#######################
we use hibernate 2.1.2
query:
Hibernate: select geschaefts0_.G_PARTNER_ID as G_PARTNE1_0_, case when geschaefts0__1_.G_PARTNER_ID is not null then 1 when geschaefts0_.G_PARTNER_ID is not null then 0 end as clazz_0_, geschaefts0_.KONZERN_ID as KONZERN_ID30_0_, geschaefts0_.MANDANTEN_NR_ID as MANDANTE3_30_0_, geschaefts0_.ANREDE_ID as ANREDE_ID30_0_, geschaefts0_.STAAT_ID as STAAT_ID30_0_, geschaefts0_.RECHTSFORM_ID as RECHTSFO6_30_0_, geschaefts0_.GP_STATUS_ID as GP_STATU7_30_0_, geschaefts0_.GP_ROLLE_ID as GP_ROLLE8_30_0_, geschaefts0_.REGION_ID as REGION_ID30_0_, geschaefts0_.GP_WIRT_BEZ_ID as GP_WIRT10_30_0_, geschaefts0_.WAEHRUNG_ID as WAEHRUN11_30_0_, geschaefts0_.STEUERSATZ_ID as STEUERS12_30_0_, geschaefts0_.NAME as NAME30_0_, geschaefts0_.NAME2 as NAME230_0_, geschaefts0_.ABTEILUNG as ABTEILUNG30_0_, geschaefts0_.KURZNAME as KURZNAME30_0_, geschaefts0_.DEBITOREN_NR as DEBITOR17_30_0_, geschaefts0_.KREDITOREN_NR as KREDITO18_30_0_, geschaefts0_.KUNDEN_NR as KUNDEN_NR30_0_, geschaefts0_.STRASSE as STRASSE30_0_, geschaefts0_.PLZ as PLZ30_0_, geschaefts0_.ORT as ORT30_0_, geschaefts0_.HAUSNUMMER as HAUSNUMMER30_0_, geschaefts0_.TELEFON_NR as TELEFON_NR30_0_, geschaefts0_.TELEFON_NR2 as TELEFON25_30_0_, geschaefts0_.FAX_NR as FAX_NR30_0_, geschaefts0_.E_MAIL as E_MAIL30_0_, geschaefts0_.POSTFACH as POSTFACH30_0_, geschaefts0_.PLZ_POSTFACH as PLZ_POS29_30_0_, geschaefts0_.PLZ_ORT as PLZ_ORT30_0_, geschaefts0_.KENN_NR as KENN_NR30_0_, geschaefts0_.VERSICH_NR as VERSICH_NR30_0_, geschaefts0_.BEMERKUNG as BEMERKUNG30_0_, geschaefts0_.ADRESSE_ID as ADRESSE_ID30_0_, geschaefts0_.VERKAUFSLEITER_ID as VERKAUF35_30_0_, geschaefts0_.KUNDENBETREUER_ID as KUNDENB36_30_0_, geschaefts0_.MITARBEITER_ID as MITARBE37_30_0_, geschaefts0_.MITARB_ID_INS as MITARB_38_30_0_, geschaefts0_.MITARB_ID_UPD as MITARB_39_30_0_, geschaefts0_.TS_INSERT as TS_INSERT30_0_, geschaefts0_.TS_UPDATE as TS_UPDATE30_0_, geschaefts0__1_.BAHNSTELLE as BAHNSTELLE34_0_, geschaefts0__1_.KOSTENSTELLE as KOSTENST3_34_0_, geschaefts0__1_.MITARB_ID_INS as MITARB_I4_34_0_, geschaefts0__1_.MITARB_ID_UPD as MITARB_I5_34_0_, geschaefts0__1_.TS_INSERT as TS_INSERT34_0_, geschaefts0__1_.TS_UPDATE as TS_UPDATE34_0_ from G_PARTNER geschaefts0_ left outer join AV_G_PARTNER geschaefts0__1_ on geschaefts0_.G_PARTNER_ID=geschaefts0__1_.G_PARTNER_ID where geschaefts0_.G_PARTNER_ID=?
actuallaly our problem is in mapping our persistent objects to our business objects, when we are searching for X-business objects, we're expecting to get persistent objects of X . but we're getting persistent object for the subclass. And then we get a ClassCastException later, if we try to write from persistent object to business object.
kersten
|