In the latest Doctrine on Symfony2, trying to work out several bi-directional relationships between two objects.
The ownerβs owner object has one mailing address and then several secondary addresses in the collection, and I delete () the Person, I want all his addresses to be deleted as well (but deleting the address should not delete the Person), but I get this error -
An exception occurred while executing 'DELETE FROM address WHERE id = ?' with params {"1":"fb5e47de-2651-4069-b85e-8dbcbe8a6c4a"}: [PDOException] SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`db`.`address`, CONSTRAINT `FK_633704 C29C1004E` FOREIGN KEY (`person_id`) REFERENCES `person` (`id`))
in
class Person { private $postalAddress; private $otherAddresses; } class Address { private $person; }
I thought it was possible because
inversedBy="postalAddress, otherAddresses"
I do not think multiple inversedBy is supported; then i also tried to change
@ORM\JoinColumn(nullable=false)
to be null but i still get the error.
This is obviously not about the trivial example of Person / Address, but about something more complex, but it was my best attempt at abstraction.
I'm sure I missed something obvious. Can anyone help?
gingerCodeNinja
source share