Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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.
Hi James
Do you have a failing test case ?
Could you attach/paste your entity please ?
Thanks