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!