I have two tables say parent and child.
PARENT STRUCTURE
ID || NAME
primary key is ID
CHILD STRUCTURE
ID || NAME || PAREND_ID
primary key is ID
foreign key is PARENT_ID
The parent class is as follows:
class parent {
private String id;
private String name;
//getter and setter methods
}
The child class is as follows
class child {
private String id;
private String name;
private String parent_id;
//getter and setter methods
}
The hibernate mapping for parent is as follows:
<hibernate-mapping>
<class name = "parent" table="parent"></class>
<id.....>....<id>
<property name = "name" column = "NAME"/>
</hibernate-mapping>
<hibernate-mapping>
<class name = "child" table="child"></class>
<id.....>....<id>
<property name = "name" column = "NAME"/>
<property name = "parent_id" column = "PARENT_ID"/>
</hibernate-mapping>
I want that if I change the id of parent, the parent_id column in child table should also get updated with the new value. Also the association is unidirectional from parent to child and one parent can have many child. Can you help me with this. Thanks