删除实例传递给merge,org.hibernate.ObjectDeletedException,@ ManyToOne根本原因,为什么?

时间:2012-01-23 10:08:17

标签: hibernate spring java-ee

以下函数似乎是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会产生什么影响?

0 个答案:

没有答案