以下函数似乎是org.hibernate.ObjectDeletedException的根本原因:当我请求删除选项时,传递给merge的已删除实例:[com.zetorv.product.pid.model.ServerResponseOption#]; < / p>
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "command", nullable=false)
public BasicMenuCommand getCommand() {
return this.command;
}
但是,当我将@ManyToOne行更改为仅@ManyToOne
删除(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
部分时,它可以正常工作;
@ManyToOne
@JoinColumn(name = "command", nullable=false)
public BasicMenuCommand getCommand() {
return this.command;
}
执行保存/更新的代码实际上是:return this.entityManager.merge(object);
一般而言,从@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
更改为@ManyToOne
会产生什么影响?