Thank you Dwightd for reply. My problem evolved because I went into many many tries, unsuccessfull until now. Before posting all my new code I advise you that, because of I'm from Italy, the classes names are in italian language.
Ente.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="siai.Ente" table="ENTE">
<id name="idEnte" type="integer">
<column name="ID_ENTE" />
<generator class="native" />
</id>
<one-to-one name="tipoEnte" class="siai.TipoEnte" cascade="none" outer-join="auto" constrained="false">
<formula>''</formula>
</one-to-one>
<property name="tipoEnteNome" type="integer">
<column name="TIPO_ENTE_NOME" not-null="true" />
</property>
<property name="nome" type="string">
<column name="NOME" length="45" not-null="true" />
</property>
<property name="indirizzo" type="string">
<column name="INDIRIZZO" length="45" not-null="true" />
</property>
<property name="cap" type="string">
<column name="CAP" length="45" not-null="true" />
</property>
<property name="comune" type="string">
<column name="COMUNE" length="45" not-null="true" />
</property>
<property name="provincia" type="string">
<column name="PROVINCIA" length="45" not-null="true" />
</property>
<property name="isDelegato" type="boolean">
<column name="IS_DELEGATO" not-null="true" />
</property>
<property name="isStapf" type="boolean">
<column name="IS_STAPF" not-null="true" />
</property>
<property name="stapfControllore" type="integer">
<column name="STAPF_CONTROLLORE" not-null="true" />
</property>
</class>
</hibernate-mapping>
TipoEnteCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="siai.TipoEnte" table="TIPO_ENTE">
<id name="idTipoEnte" type="integer">
<column name="ID_TIPO_ENTE" />
<generator class="native" />
</id>
<property name="descrizione" type="string">
<column name="DESCRIZIONE" length="45" not-null="true" />
</property>
</class>
</hibernate-mapping>
'Ente' class:
Code:
...
private TipoEnte tipoEnte;
...
public TipoEnte getTipoEnte(){
return this.tipoEnte;
}
public void setTipoEnte(TipoEnte tipoEnte){
this.tipoEnte = tipoEnte;
}
With this situation I got a relationship between Ente's Primary Key and TipoEnte's Primary Key. Instead I wish a relation between Ente's TIPO_ENTE_NOME column and TipoEnte's Primary Key. How could I achieve this? Thank you very much for all help you could give me.