Doctrine 双向关系的意外行为

Doctrine unexpected behavior on bidirectional relations

我定义了两个具有双向关系的实体:

一个

\App\Entity\Product:
...
  manyToOne:
    productSet:
      targetEntity: App\Entity\ProductSet
      inversedBy: products
      cascade: ["all"]
      joinColumn:
        onDelete: RESTRICT
...

还有两个

\App\Entity\ProductSet:
...
  oneToMany:
    products:
      targetEntity: App\Entity\Product
      mappedBy: productSet
      cascade: ['all']
...

如果我删除所有相关的 Product 实体,相关的 productSet 实体也会自动删除。我不明白为什么。我如何防止这种行为?

学说版本 2.6.3

根据文档 - https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/working-with-associations.html#transitive-persistence-cascade-operations

并且您有 cascade: ['all'] - 行为符合预期