孙 object 没有更新
grandchild object does not updated
我有一个 parent、一个 child 和一个 grandchild object。
问题是,当我删除应用程序中的 grandchildren 并保存时
parent object, grandchildren 更改不会更新。
在ParentClass
@OneToMany(fetch = FetchType.EAGER, mappedBy = "parent")
@ForeignKey(name = "FK_1")
@Cascade({CascadeType.ALL})
private Set<Child> children;
在ChildClass
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "parent")
@XmlTransient
private parent parent;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "child")
@ForeignKey(name = "FK_2")
@Cascade({CascadeType.ALL})
private Set<GrandChild> grandchildren;
盛大ChildClass
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "child", nullable = false)
@XmlTransient
private Child child;
我使用 hibernate 4.2.2.Final.
有什么想法吗?
尝试将 orphanRemoval 添加到您的 collections。
@OneToMany(fetch = FetchType.EAGER, mappedBy = "parent", orphanRemoval=true)
@OneToMany(fetch = FetchType.EAGER, mappedBy = "child", orphanRemoval=true)
我有一个 parent、一个 child 和一个 grandchild object。 问题是,当我删除应用程序中的 grandchildren 并保存时 parent object, grandchildren 更改不会更新。
在ParentClass
@OneToMany(fetch = FetchType.EAGER, mappedBy = "parent")
@ForeignKey(name = "FK_1")
@Cascade({CascadeType.ALL})
private Set<Child> children;
在ChildClass
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "parent")
@XmlTransient
private parent parent;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "child")
@ForeignKey(name = "FK_2")
@Cascade({CascadeType.ALL})
private Set<GrandChild> grandchildren;
盛大ChildClass
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "child", nullable = false)
@XmlTransient
private Child child;
我使用 hibernate 4.2.2.Final.
有什么想法吗?
尝试将 orphanRemoval 添加到您的 collections。
@OneToMany(fetch = FetchType.EAGER, mappedBy = "parent", orphanRemoval=true)
@OneToMany(fetch = FetchType.EAGER, mappedBy = "child", orphanRemoval=true)