posted 15 years ago
Sagar, i have tried using manytoone mapping and i am able to persist both entities for both conditions :- CascadeType.PERSIST and CascadeType.All
public class Employee {
...............
@ManyToOne(cascade=CascadeType.PERSIST)
@JoinColumn(name="department_id")
private Department department;
}
I did not get any issue here.
below is the sample code, which i have used.
Employee emp = new Employee();
emp.setName("Sunil");
emp.setSex("M");
Department dept = new Department();
dept.setDepartmentName("HR1");
em.getTransaction().begin();
emp.setDepartment(dept);
em.persist(emp);
-Sunil