mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1566: Can't create bidirectional OneToMany When a ManyToOne relation exists #1964
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Dec 27, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user agora:
I tried to create a bidirectional relation between two entities (LunchTable and Zone) like this LunchTable <--- n-1 ---> Zone.
The relation ManyToOne in LunchTable work perfectly. But the OneToMany doesn't work : when i try to insert into the DB a LunchTable row, I have : integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
supproject.lunchtable, CONSTRAINTFK*B76A375B9F2C3FABFOREIGN KEY (zone*id) REFERENCESZone(id) ON DELETE CASCADE)My Zone entity is in relation with another one called Restaurant ( like this : Zone <--- 1-n ---> Restaurant )
These two relations work perfectly.
The problem append when i set up the OneToMany relation in the Zone entity.
In order to solve this problem, i have to redo the relation with a mysql client or phpmyadmin, and it work.
My files : http://pastebin.com/TNC06Ffg
@doctrinebot commented on GitHub (Dec 27, 2011):
Comment created by agora:
I investigate about the problem and i find something : if i replace my Zone entity by a Area entity (with the same code except some adaptations) it work.
So, I put on a reservation of the word 'Zone' in the source code of Doctrine (or maybe Symfony ?)
@doctrinebot commented on GitHub (Jan 16, 2012):
Comment created by @guilhermeblanco:
There's no restriction on Doctrine side for word "Zone".
@doctrinebot commented on GitHub (Mar 14, 2012):
Comment created by @beberlei:
The error message says whats wrong. Zone_id to be set does not seem to exist in The Zone table. I would guess your Zone entity has a wrong mapping, either wrong @Table or missing @Entity or something.
@doctrinebot commented on GitHub (Mar 14, 2012):
Issue was closed with resolution "Invalid"