-->
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.  [ 5 posts ] 
Author Message
 Post subject: Verständnisproblem Foreignkey List
PostPosted: Sun Jul 30, 2006 4:09 pm 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
Hi ich habe folgendes Konstrukt:

Eine Person hat eine Liste von Adressen; wenn ich nun eine Person mit Adressen via Hibernate in die Datenbank schreibe, dann sind alle Einträge in der Foreignkey-Spalte id_person der Tabelle Adressen null. Hibernate schafft es dennoch jeder Person die richtigen Adressen zuzuordnen, aber wie?!? ;)

thx...QStorm

achso P.S.: ich benutze Hibernate 3 und MySQL


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 3:53 pm 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
hat keiner ne idee?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 3:27 am 
Beginner
Beginner

Joined: Fri May 19, 2006 11:34 am
Posts: 29
Sollen wir hier in die Kristallkugel schauen? Das hat leider noch nie geklappt.

Wäre da vielleicht hilfreich, wenn du deine Mappings und deinen Code posten würdest...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 2:57 am 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
doppelpost...


Last edited by QStorm on Sun Aug 06, 2006 4:58 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 2:57 am 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
DBSpeicherbar:
Code:
package appl;
class DBSpeicherbar {
   private long oid = -1;
   DBSpeicherbar() {}
   final long getOid() { return this.oid; }
   final void setOid(final long i_oid) { this.oid = i_oid; }
}


Person:
Code:
package appl;
public final class Person extends DBSpeicherbar {
   private String name;
   private List<Adresse> adressen = new ArrayList<Adresse>();
   Jaeger() {}
   public final String getName() { return this.name; }
   public final List<Adresse> getAdressen() { return this.adressen; }
   final void setAdressen(final List<Adresse> i_adressen) { this.adressen = i_adressen; }
   final void setName(final String i_name) { this.name = i_name; }
}


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   
<hibernate-mapping>
   <class name="appl.Person" table="PERSON">
      <id name="oid" type="java.lang.Long">
         <column name="OID" sql-type="BIGINT"/>
         <generator class="native" />
      </id>

      <property name="name">
            <column name="NAME"/>
         </property> 

      <list name="adressen" table="ADRESSEN" cascade="save-update, delete">
         <key column="ID_JAEGER" />
         <list-index column="SORTIERUNG" />
         <one-to-many class="appl.Adresse" />
      </list>
   </class>
</hibernate-mapping>


Adresse:
Code:
package appl;

public final class Adresse extends DBSpeicherbar {
        private String strasseHausnummer;
   private String plz;
   private String stadt;

   Adresse() {
      this("", "", "");
   }

   public final String getStrasseHausnummer() { return this.strasseHausnummer; }
   public final String getPlz() { return this.plz; }
   public final String getStadt() { return this.stadt; }
   final void setStrasseHausnummer(final String i_strasseHausnummer) { this.strasseHausnummer = i_strasseHausnummer; }
   final void setPlz(final String i_plz) { this.plz = i_plz; }
   final void setStadt(final String i_stadt) { this.stadt = i_stadt; }

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   
<hibernate-mapping>
   <class name="appl.Adresse" table="ADRESSEN">
      <id name="oid" type="java.lang.Long">
         <column name="OID" sql-type="BIGINT"/>
         <generator class="native" />
      </id>

         <property name="strasseHausnummer">
            <column name="STRASSE_HAUSNUMMER"/>
         </property> 
            
       <property name="plz">
            <column name="PLZ"/>
         </property> 
      
         <property name="stadt">
            <column name="STADT"/>
         </property>
   </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.  [ 5 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.