Symfony 3.0 nested entities not saving

前端 未结 1 1832
半阙折子戏
半阙折子戏 2021-01-07 06:31

So I have an Experiment Entity which has many RNASeq entities. However, when I try to save an Experiment with an RNASeq entry (via the newAction), only the Expe

相关标签:
1条回答
  • 2021-01-07 07:08

    This is a very common issue. You need to take care of cross referencing your objects. Doctrine does not do this automatically though many people initially seem to think it will.

    class Experiment {
      public function addRNASeq($seq) {
        $this->seqs[] = $seq;
        $seq->setExperiment($this);  // This is what you are missing
    

    And add the attribute cascade=all to your Experiment::seqs property. Then you won't need to explicitly persist the seq entities.

    0 讨论(0)
提交回复
热议问题