在尝试为父级执行session.merge(entity)
时,我得到的是没有给定标识符的行存在异常。基本上,我在同一个表中有@OnetoMany。以下是我遵循的步骤。
session.delete(entity)
删除了孩子,并使用iterator remove将其从父实体中删除。 public class Account{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idgen")
protected Long id;
@Column(name = "SOME_ID")
private String someId;
private static final long serialVersionUID = 1L;
@JoinColumn(name = "PARENT_ACCT")
@ManyToOne
private Account parentAccount;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy =
"parentAccount")
private Set<Account> sleeves;
}