am new to Hibernate learning entity mapping using hibernate framework via instead of annotation am using XML for mapping the entities
Here I have two classes Employee and Address [Address is the target class and Employee is the source class i.e is Employee table will have the foreign key column refers to Address table primary key]
class Employee{
String name;
int id;
Address addr;
//getter and setter methods
}
class Address{
String state;
String city
}
mapping.hbm.xml file:-
<hibernate-mapping>
<class name="Employee" table="emp">
<id name="id" column="id">
<generator class="assigned"/>
</id>
<property name="name" column="emp_name"/>
<one-to-one name="addr" class="Address" foreign-key="addr_id" cascade="all"/>
</class>
<!--mapping for Address Entity-->
<class name="Address" table="address>
<property name="city"/>
<property name"state"/>
</class>
</hibernate-mapping>
Note:- am using MySQL in table level I did not add a foreign key constraint to the employee table
And My Question while am try to save employee entity addr_id value is not stored in employee table how to resolve this issue.IN web most of the things are using annotations or shared a primary key.How to solve this issue kindly help me