i have 2 class. Parent and child. as follows:
@Entity
@Table(name = "parent")
public class Parent implements Serializable {
private String name;
private List<Child> childs;
@OneToMany(mappedBy="parent")
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
public List<Child> getChilds() {
return childs;
}
@Id
@Column(name="parent_name")
public String getName() {
return name;
}
}
>
@Entity
@Table(name = "child")
public class Child implements Serializable {
@JoinColumn(name="parent_name")
private Parent parent;
public Parent getParent() {
return parent;
}
public void setParent(Parent parent) {
this.parent = parent;
}
}
when i use session.save(parent) it saves parent and child in the database but the column of parent identifier in child table will remain null. so what is the problem?