我有两个表,这些类:@OneToMany删除不活像
全球史:
@ManyToOne
@JoinColumn(name = "ID_HISTORY", nullable = true)
private History history;
和历史一个简单的类。
我想undrestand为什么当我尝试删除全球历史我得到这个错误:
org.hibernate.exception.ConstraintViolationException:不能删除或更新父行:外键约束失败
我有两个表,这些类:@OneToMany删除不活像
全球史:
@ManyToOne
@JoinColumn(name = "ID_HISTORY", nullable = true)
private History history;
和历史一个简单的类。
我想undrestand为什么当我尝试删除全球历史我得到这个错误:
org.hibernate.exception.ConstraintViolationException:不能删除或更新父行:外键约束失败
看起来好像你想要DELETE
你的表中有一些记录在Parent-Child relationship
。 检查您是否有Parent-Child relationship
中的表格。这就像当你有一张桌子Department
(假设为Parent table
,这里你有所有部门唯一ID)和Employees
表(假设为Child table
(外键),这里你有Department
表中雇员所属的department_id keys
) 。当你想要Update OR Delete
Parent table
并且没有referential actions
时,那么数据库保护Child's table
来自这些操作的数据;