Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
hibernate 3.0
I have mapped a many-to-one relation between 2 tables, using 2 different columns. Class EVNAmbito is the one part. To implement the relation, I declared a properties set, named idnatural.
Mapping documents:
Code:
<class name="EVNAmbito" table="TBREVTAMBITO" lazy="false" catalog="MAPEVN_PROP" mutable="false">
<id name="id" type="string" column="CDAMBITO" length="16">
<generator class="assigned" />
</id>
<properties name="idnatural">
<many-to-one name="organismoDestino" class="EVNOrganismoDestino" column="CDORGANISMODEST" fetch="join" not-null="true" />
<many-to-one name="tipoAsunto" class="EVNTipoAsunto" column="CDTIPOASUNTO" fetch="join" not-null="true" />
</properties>
</class>
Code:
<!-- Relación de sólo lectura. Necesaria para filtrar usando la lista de ámbitos permitidos al usuario -->
<many-to-one name="ambito" class="EVNAmbito" property-ref="idnatural" insert="false" update="false" fetch="select">
<column name="CDORGDESTINO"/>
<column name="CDTIPOASUNTO"/>
</many-to-one>
The thing, is that those 2 properties, form also the natural-id of the class, so I'd like to declare the natural-id, and use it for the relation, instead of the properties. The problem I have, is that I don't know how to refer two the natural-id in the many side. I tried with natural-id, naturalId, naturalid in the property-ref, but does not work. Code should be someting like:
Code:
<class name="EVNAmbito" table="TBREVTAMBITO" lazy="false" catalog="MAPEVN_PROP" mutable="false">
<id name="id" type="string" column="CDAMBITO" length="16">
<generator class="assigned" />
</id>
<natural-id mutable="false">
<many-to-one name="organismoDestino" class="EVNOrganismoDestino" column="CDORGANISMODEST" fetch="join" not-null="true" />
<many-to-one name="tipoAsunto" class="EVNTipoAsunto" column="CDTIPOASUNTO" fetch="join" not-null="true" />
</natural-id>
</class>
Code:
<!-- Relación de sólo lectura. Necesaria para filtrar usando la lista de ámbitos permitidos al usuario -->
<many-to-one name="ambito" class="EVNAmbito" property-ref="???????" insert="false" update="false" fetch="select">
<column name="CDORGDESTINO"/>
<column name="CDTIPOASUNTO"/>
</many-to-one>
Is possible to do that?