-->
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.  [ 2 posts ] 
Author Message
 Post subject: Einfache 1:n Beziehung
PostPosted: Thu May 24, 2007 4:39 am 
Newbie

Joined: Wed May 16, 2007 9:55 am
Posts: 8
Hallo,
ich versuche gerade eine einfache 1:n Beziehung zu erstellen. D.h. ein Nutzer hat die Möglichkeit n Nachrichten zu schreiben. Ich habe Probleme die Tabellen zu verknüpfen, weil ich nicht genau weiß welche Angaben ich machen muss. Es wäre sehr nett, wenn mir jemand ein paar Tips geben könnte!

Aktuell erhalte ich folgende Fehlermeldung:
Association references unmapped class: Mitteilungen

Nutzer.hbm.xml
Code:
<hibernate-mapping>
    <class name="de.jsfpraxis.friends.model.Nutzer" table="NUTZER" schema="PUBLIC">   
       
        <id name="id" type="int">
            <column name="ID" />
            <generator class="identity" />
        </id>
       
        <property name="vorname"     type="string"  length="30" />
        <property name="nachname"    type="string"  length="30" />
        ...
       
         <set name="mitteilungen" inverse="true">
            <key>
                <column name="ID" not-null="true" />
            </key>
                <one-to-many class="Mitteilungen" />
   </set>

        </class>
</hibernate-mapping>


Mitteilungen.hbm.xml
Code:
<hibernate-mapping>
   <class name="de.jsfpraxis.friends.model.Mitteilungen"
      table="Mitteilungen" schema="PUBLIC">

      <id name="id" type="int">
         <column name="ID" />
         <generator class="identity" />
      </id>
      
       <many-to-one name="nutzer" class="Nutzer">
                     <column name="ID" not-null="true" />
                 </many-to-one>

      <property name="empfaenger" type="string" length="30" />
      <property name="gesendeteNachricht" type="string" length="400" />
   
   </class>
</hibernate-mapping>



Top
 Profile  
 
 Post subject: Hier die Lösung für alle die es interessiert,...
PostPosted: Sat May 26, 2007 10:10 am 
Newbie

Joined: Wed May 16, 2007 9:55 am
Posts: 8
Habe das Problem so lösen können:

Code:
<hibernate-mapping>
    <class name="de.jsfpraxis.friends.model.Mitteilungen" table="MITTEILUNGEN" schema="PUBLIC">
        <id name="id" type="int">
            <column name="ID" />
            <generator class="identity" />
        </id>
        <many-to-one name="nutzer" class="de.jsfpraxis.friends.model.Nutzer" fetch="select">
            <column name="NUTZER_ID" not-null="true" />
        </many-to-one>
        <property name="empfaenger" type="string">
            <column name="EMPFAENGER" length="30" not-null="true" />
        </property>
        <property name="gesendetenachricht" type="string">
            <column name="GESENDETENACHRICHT" length="400" not-null="true" />
        </property>
    </class>
</hibernate-mapping>


Code:
<hibernate-mapping>
    <class name="de.jsfpraxis.friends.model.Nutzer" table="NUTZER" schema="PUBLIC">
        <id name="id" type="int">
            <column name="ID" />
            <generator class="identity" />
        </id>
   
        <property name="vorname" type="string">
            <column name="VORNAME" length="30" not-null="true" />
        </property>
        <property name="nachname" type="string">
            <column name="NACHNAME" length="30" not-null="true" />
        </property>
        ...
        <set name="mitteilungens" inverse="true">
            <key>
                <column name="NUTZER_ID" not-null="true" />
            </key>
            <one-to-many class="de.jsfpraxis.friends.model.Mitteilungen" />
        </set>
    </class>
</hibernate-mapping>



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

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.