hibernate注解级联删除时,报错(不能删除外键)求大神指点
我分别配了
一对多,
@OneToMany(targetEntity = UserEntity.class,fetch = FetchType.LAZY)
@JoinColumn(name = "type")
@Cascade(value = {CascadeType.SAVE_UPDATE,CascadeType.DELETE_ORPHAN,CascadeType.ALL})
private Set<UserEntity> userSet;
多对一
@ManyToOne
@JoinColumn(name = "t_group_id", referencedColumnName = "t_id", unique = false)
@Cascade(CascadeType.ALL)
private GroupEntity groupEntity;
但是通过删除 group级联删除User 时 报错了
Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
ava.sql.BatchUpdateException: Cannot delete or update a parent row: a foreign key constraint fails (`1603b_shixun1`.`t_users`, CONSTRAINT `FKA115CA7D8A3D944E` FOREIGN KEY (`t_group_id`) REFERENCES `t_groups` (`t_id`))