Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-954 Look into deferring foreign key checks until flush finished
  3. DDC-890

Association mapping 'One-To-Many, Self-referencing' with cascade and removes fk onDelete=restrict

    Details

    • Type: Sub-task Sub-task
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      By using the association mapping 'One-To-Many, Self-referencing' removes the cascade.

      How to follow the example below, and removed the first parent entity after the children entities.

      And if you use foreign key onDelete=restrict the referential integrity error

      A possible solution in the patch attached below

      Category.php
      <?php
      /** @Table(name="category") */
      class Category
      {
          /**
           * @Id
           * @Column(name="id")
           */
          public $id;
      
          /**
           * @OneToMany(targetEntity="Category", mappedBy="parent", cascade={"remove"})
           */
          public $children;
      
          /**
           * @ManyToOne(targetEntity="Category", inversedBy="children")
           * @JoinColumn(name="parent_id", referencedColumnName="id")
           */
          public $parent;
      
          public function __construct() {
              $this->children = new \Doctrine\Common\Collections\ArrayCollection();
          }
      }
      ?>
      
      CREATE TABLE `category` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `parent_id` int(10) unsigned DEFAULT NULL,
        `name` varchar(50) NOT NULL,
        PRIMARY KEY (`id`),
        KEY `fk_id_parent_id` (`parent_id`),
        CONSTRAINT `fk_id_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `category` (`id`)
      ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC
      
      1. patch.diff
        0.8 kB
        André Ribeiro de Miranda

        Activity

        André Ribeiro de Miranda created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Parent DDC-954 [ 12259 ]
        Issue Type Bug [ 1 ] Sub-task [ 5 ]
        Hide
        Guilherme Blanco added a comment -

        Seems to be fixed already in master.
        Closing the ticket.

        Show
        Guilherme Blanco added a comment - Seems to be fixed already in master. Closing the ticket.
        Guilherme Blanco made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Roman S. Borschel [ romanb ] Guilherme Blanco [ guilhermeblanco ]
        Fix Version/s 2.3 [ 10185 ]
        Fix Version/s Git Master [ 10100 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12144 ] jira-feedback [ 14655 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14655 ] jira-feedback2 [ 16519 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 16519 ] jira-feedback3 [ 18772 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-890, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            André Ribeiro de Miranda
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: