Fixed ConstraintViolationException when deleting a record