-->
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] Same columns in much tables. How to define ids...
PostPosted: Wed May 09, 2007 11:11 am 
Newbie

Joined: Wed May 09, 2007 10:35 am
Posts: 1
Hibernate version: 3.2.2
Mapping documents:
Code:
<class name="model.Pagina" table="PTT_PAGINA" >
      <composite-id name="paginaKey" class="model.PaginaKey">
           <key-property name="IDpagina" type="integer" column="ID_pagina" />
           <key-property name="versionePagina" type="integer" column="ID_versione"/>
       </composite-id>
      <property name="nome" type="string"/>
       <property name="descrizione" type="string"/>
       <property name="keywords" type="string"/>
       <property name="pubblicatoCollaudo" column="pubb_coll" type="boolean"/>
       <property name="pubblicatoProduzione" column="pubb_prod" type="boolean"/>
      <many-to-one name="props" class="model.PaginaProperties" column="ID_pagina" insert="false" update="false" />
      <set name="elementi" inverse="true">
          <key>
              <column name="IDpagina"/>
              <column name="versionePagina"/>
          </key>
          <one-to-many class="model.Elemento"/>
      </set>
            
   </class>

<class name="model.Elemento" table="PTT_PAGINA_ELEMENTI" >
       <composite-id name="id" class="RigheMenuT1Key">
          <key-many-to-one name="tipoElemento" class="model.TipoElemento" />
           <key-many-to-one name="paginaKey" class="model.PaginaKey" />
            <key-many-to-one name="menuKey" class="model.ElementoKey" /> 
      </composite-id>
      <property name="ordine" column="ordine"/>
   </class>


I have this documentation:
ER Schema

Class diagram

The problem is in the model.Elemento mapping. The first one should be correct.
I have a key composed by 5 columns, but 2 columns are the same of model.Pagina class. How can I reference that columns (wrapped in the PaginaKey class) in the Elemento definition? They are part of Elemento's primary key too.
I think that my mapping is absolutely wrong. This is the first time I use hibernate. I read the whole documentation but I didn't find the answer. Can you help me? Thanks!


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.