-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: bekomme one-to-many - Verbindung nicht hin
PostPosted: Thu Aug 27, 2009 5:56 am 
Newbie

Joined: Thu Aug 13, 2009 4:52 am
Posts: 12
Hi there :)

ich habe 2 Tabellen:
fads: (beinhaltet kunden-datensätze ... 1 Kunde kann mehrere Kontakte haben [1:n])
diese spalten identifizieren einen Kunden: ADSKEY, ADSBETNR

kontakt: (beinhaltet Kontakte mit einem Kunden ... n Kontakte gehören zu 1 Kunden [n:1])
primary key: koknr
Spalten, die den Kunden identifizieren, zu dem der Kontakt gehört: kokdnr (=fads.ADSKEY) und korgbt (=fads.ADSBETNR)

es gibt keine foreign keys

mapping-dateien und klassen sind bereits erstellt (Fads.java, FadsDAO.java, FadsId.java, Fads.hbm.xml, Kontakt.java, KontaktDAO.java, Kontakt.hbm.xml)

jetzt bekomme ich die one-to-many verbindung zu den kontakten einfach nicht hin..
wie bekomme ich die kontakte eines kunden über das Fads - Objekt..?

hab in der Fads.hbm.xml etwas rumgebastelt... aber ohne erfolg
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>
      <!-- .. und noch viel mehr properties.. -->

   <!-- sowas in der art sollte irgendwie funktionieren, oder? -->
        <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>


bin für jeden hinweis dankbar!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.