Hi all,
I have a quite newbie question for you. I have my app with a simple One-To-One association and I have a problem managing the foreign key between the two associated class.
Domain objects:
Code:
public class Fonte {
private int idFonte;
private String nome;
private String link;
private NavXML xmlDescriber; //one-to-one associated object with foreign key on the DB
//getters&setters
}
public class NavXML {
private String contentCrawling;
private String contentWrapping;
private int idNavXML;
private String description;
//getters&setters
}
and here we have the mapping files:
Code:
<hibernate-mapping>
<class name="Fonte" table="FONTI">
<id name="idFonte" column="id_fonte"><generator class="native"/> </id>
<property name="nome" column="nome"/>
<property name="link" column="link"/>
<one-to-one name="xmlDescriber" class="NavXML" cascade="all" constrained="true" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="NavXML" table="XMLNAV">
<id name="idNavXML" column="id_xml_nav"> <generator class="native"/> </id>
<property name="contentCrawling" column="content_crawling" type="text"/>
<property name="contentWrapping" column="content_wrapping" type="text" />
<property name="description" />
</class>
</hibernate-mapping>
in the DB (MySQL) I have a foreign key between the table FONTI to the table XMLNAV based on the id_nav_xml .
The problem is that
I can't get the same id assigned on a newly created NAVXML object and in the field of the foreign key in the FONTI table.
In other words, how can I force to have the same value in the XMLNAV table id field and in the FONTI table foreign key field?
At the moment I get a NULL value in the foreign key field of the FONTI table when I try to insert an object of type Fonte.
Thank you in advance.
Regards
PS:Sorry for my English