-->
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: Mapping so OK?
PostPosted: Sun Dec 11, 2005 11:22 am 
Newbie

Joined: Mon Dec 05, 2005 4:09 pm
Posts: 2
Hibernate version: 3.0

Ich habe einmal eine Tabelle Katalog und eine Tabelle Kategorie (m:n), die Zuordnung einer Kategorie zu welchem Katalog Sie gehört findet folglich in der Tabelle KatalogKategorie statt.

Die eigentliche Hierarchie eines Kataloges, die sich durch ParentChild Beziehungen der Kategorien aufbaut findet in der Tabelle SubKategoriestruktur statt.

Meine Frage bilde ich diesen Sachverhalt korrekt in meinen Mappings ab? Oder habe ich evtl. einen grundlegenden Denkfehler?

Dies gilt insbesondere für die SubKategoriestruktur Tabelle.

Klassenaufbau...unter den Mappings



Mapping documents:

<class name="Katalog.Katalog" table="Katalog">



<id name="id" type="long" unsaved-value="null" >

<column name="KatalogID" not-null="true"/>

<generator class="native"/>

</id>





<property name="name">

<column name="name" length="255" not-null="true"/>

</property>



<set name="Kategorie"

table="KatalogKategorie"

inverse="true"

cascade="save-update">

<key column="KatalogID" />

<many-to-many class="Katalog.Kategorie" column="KategorieID"/>

</set>

</class>

----------------------------------------------------------------------------------
<class name="Katalog.Kategorie" table="Kategorie">

<id name="id" type="long" unsaved-value="null" >

<column name="KategorieID" not-null="true"/>

<generator class="native"/>

</id>





<property name="name">

<column name="name" length="80" not-null="true"/>

</property>



<set name="Katalog"

table="KatalogKategorie"

cascade="save-update">

<key column="KategorieID" />

<many-to-many class="Katalog.Katalog" column="KatalogID" />

</set>



</class>
------------------------------------------------------------------------------------


<class name="Katalog.SubKategorieStruktur" table="SubKategorieStruktur">



<id name="id" type="long" unsaved-value="null" >

<column name="SubKategorieStrukturID" sql-type="bigint" not-null="true"/>

<generator class="native"/>

</id>



<many-to-one name="KatalogID" class="Katalog.Katalog" column="KatalogID"/>

<many-to-one name="ParentKategorie" class="Katalog.Kategorie" column="ParentKategorieID"/>

<many-to-one name="ChildKategorie" class="Katalog.Kategorie" column="ChildKategorieID"/>



</class>





Klassen:
Katalog
...private Long id;
private String name;
private Set Kategorie = new HashSet();...

Kategorie
...private Long id;
private String name;
private Set Katalog = new HashSet();...

SubKategorieStructure
...private Long id;
private Katalog katalog;
private Kategorie ParentKategorie;
private Kategorie ChildKategorie;...


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.