Class A {
private String name;
}
Class B {
@OneToOne(orphanRemoval = true)
@NotNull
@JoinColumn(name = "a")
private A a;
}
A-B是一对一的关系。 当我打电话
b.getA().setName("fake");
aDao.save(b.getA());
bDao.delete(b);
我得到"error": "could not execute statement; SQL [n/a]; constraint [b_a_fkey]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement"
但我没有在A类上设置cascade.delete,为什么bDao.delete(b)
会抛出错误?
感谢。