-->
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 between 4 tables
PostPosted: Fri Jun 24, 2005 5:47 am 
Newbie

Joined: Fri Jun 24, 2005 5:34 am
Posts: 18
Hibernate version:
3

Name and version of the database you are using:
SQL Serveur 2000


Hy every one,

my problem is not simple, I've got a relation between 3 tables and I want to make a mapping with 2 differents <map>.

Look at my DB :

Image

And, here there is my Mapping.hbm.xml :

Code:
<class name="TArticle" table="Article" optimistic-lock="version">
        <id name="id">
            <generator class="increment"/>
        </id>
        <version name="version" type="long"/>
        <property name="name"/>
        <property name="price"/>
    </class>

    <class name="TStore" table="Store" optimistic-lock="version">
        <id name="id">
            <generator class="increment"/>
        </id>
        <version name="version" type="long"/>
        <property name="name"/>
      <many-to-one name="storeBy" column="store_id" />

      <set name="recalls" inverse="true" table="Recall_Article_Store">
            <key column="store_id"/>
            <one-to-many class="TRecall" />
        </set>
    </class>

   <class name="TRecall" table="Recall" optimistic-lock="version">
      <id name="id" column="id" />
      <version name="version" />
      <property name="year"></property>
      <property name="number"></property>
      <property name="recall_version" column="version_nb"></property>
       <property name="name"></property>

      <map name="articles" table="Recall_Article_Store">
         <key column="recall_id"/>
         <index-many-to-many class="TArticle" foreign-key="article_id"/>
         <composite-element class="TArticles">
            <many-to-one name="article" column="article_id" />
            <property name="action"></property>
         </composite-element>
      </map>

      <map name="stores" table="Recall_Article_Store">
         <key column="recall_id" ></key>
         <index-many-to-many class="TStore"></index-many-to-many>
         <composite-element class="TStores">
            <property name="quantity"></property>

         </composite-element>
      </map>

   </class>


I've already try different kind of possibilities, but nothing work :
Repeated column in mapping for collection: be.uchrony.example.db.TRecall.articles column: article_id

I just want to have a TRecall class with 2 different List (Map or something else), so I'll be able to see all Articles and all Store.

in a second case I want, when I choose a Store to know how many "Quantity" of Article in the Recall the store had.


Kind regards,

- Blins.
[/code]


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.