Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Can't Fix
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: ORM
    • Labels:
      None
    • Environment:
      Ubuntu 12.04, PHP 5.3, 64 Bit, Symfony 2

      Description

      Adding the annotation indexBy causes the cascade annotation to be ignored:

      /**
      *

      • @var ArrayCollection
      • @ORM\OneToMany(targetEntity="LocationData", mappedBy="location", indexBy="name", cascade= {"persist", "remove"}

        )
        */
        protected $data;

      Will cause an error when deleting the objects:

      An exception occurred while executing 'DELETE FROM location WHERE id = ?' with params

      {"1":19306}

      :

      SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`symfony`.`location_data`, CONSTRAINT `FK_2DF7462364D218E` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`))

      Removing indexBy fixes the issue.

      My class structure is:

      Location has many LocationData
      LocationData extends AbstractData

      The name field I am trying to index by comes from the AbstractData class.

      1. AbstractData.php
        1 kB
        James Bench
      2. DDC2036Test.php
        4 kB
        Fabio B. Silva
      3. Location.php
        1 kB
        James Bench
      4. LocationData.php
        0.5 kB
        James Bench
      5. msql.log
        2 kB
        Fabio B. Silva
      6. sql_flush.log
        6 kB
        James Bench

        Activity

          People

          • Assignee:
            Fabio B. Silva
            Reporter:
            James Bench
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: