hi there!
i have to tables:
fads: (contains customer-records ... can have n contacts [1:n])
this two columns identify a customer: ADSKEY, ADSBETNR
kontakt: (contains contacts with a customer ... n contacts belong to 1 customer [n:1])
primary key: koknr
columns to identify the customer, to which the contact is related: kokdnr (=fads.ADSKEY) and korgbt (=fads.ADSBETNR)
there are no foreign keys set up.
i already have mapped the tables (Fads.java, FadsDAO.java, FadsId.java, Fads.hbm.xml, Kontakt.java, KontaktDAO.java, Kontakt.hbm.xml)
now i fail at creating a one-to-many - association ..
and how do i get the contacts by the fads - object?
i already tried to edit the Fads.hbm.xml, but without success
Fads.hbm.xml
Code:
<hibernate-mapping>
<class name="hibernate.mappings.Fads" table="fads" catalog="">
<composite-id name="id" class="hibernate.mappings.FadsId">
<key-property name="adskey" type="java.lang.Integer">
<column name="ADSKEY" />
</key-property>
<key-property name="adsbetnr" type="java.lang.Integer">
<column name="ADSBETNR" />
</key-property>
</composite-id>
<property name="adsanr" type="java.lang.Short">
<column name="ADSANR" not-null="true" />
</property>
<!-- .. and much more properties .. -->
<!-- should something like this work? -->
<map name="kontakte" cascade="all">
<key not-null="true">
<column name="ADSKEY"></column>
<column name="ADSBETNR"></column>
</key>
<map-key formula="(select ko.koknr from Kontakt where ko.adskey=Fads.id.adskey and ko.adsbetnr=Fads.id.adsbetnr" type="string"/>
<one-to-many class="hibernate.mappings.Kontakt"
not-found="ignore" />
</map>
</class>
</hibernate-mapping>
thanks in advance