I have a Class Employee which maps to a table employee.
I have another table called address which has its corresponding Address class.
Employee contains an object called Address :
Code:
class Employee{
private Address employeeAddress;
}
In my employee table I have a column called address_id which links to a row in the address table.
In my hibernate mapping file I have :
Code:
<many-to-one name="employeeAddress" class="com.dao.bean.Address" unique="true" cascade="all" column="address_id"/>
When I add a new employee the new row is added to the address table and the address_id in the employee table matches the new row.
However when I update an employee it also creates a new row in the the address table and sets the address_id in the employee table to the new row. Fuctionaly it will still work but I cant have this table growing everytime there is an update.
Any ideas about what I am doing wrong ???
Thanks in advance
Spunog