Hi!
I have 2 sample DB tables:
1) employee (id, name, address); id is a primary key
2) salary(emp_id, salary); emp_id column is a foreign key to employee(id)
I have one persistent class Employee:
Code:
package data;
public class Employee {
private int id;
private String name, address;
private double salary; // references a column in Salary table
................... setters/getters ...........
}
How can I modify the below association mapping so that when I insert 1 record into the the Employee object/table, 1 row is also inserted into the Salary table automatically?
Code:
<class name="data.Employee" table="employee">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native" />
</id>
<property name="name" column="name" type="java.lang.String" />
<property name="address" column="address" type="java.lang.String" />
</class>
Many thanks!