-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDC-1322: Cannot persist entity with Bidirectional-ManyToOne associations #1937
Comments
Comment created by apoy2k: Corrected statements |
Comment created by @beberlei: The problem is not the how the values are inserted. A foreign key constraint fails, i.e. there is no corresponding User with id 32 in the User table, that is why you cannot insert that row. |
Comment created by apoy2k: SHOW CREATE TABLE Play; CREATE TABLE |
Comment created by @beberlei: MySQL 5.5 and InnoDB bug on MacOSX |
Issue was closed with resolution "Invalid" |
Comment created by @beberlei: |
Jira issue originally created by user apoy2k:
For the following entites:
https://gist.github.com/1129392
When I create a new "Play", using existing User and Room entities and trying to persist them
$play = new Play();
$play->setRoom($room);
$play->setUser($user);
$em->persist($play);
I get the following error:
#1452 - Cannot add or update a child row: a foreign key constraint fails (
play
, CONSTRAINTplay*ibfk_1
FOREIGN KEY (user*id
) REFERENCESUser
(id
))The executed query by Doctrine is
INSERT INTO Play (user_id, room_id) VALUES (?, ?) ({"1":1,"2":32}) [] []
But obviously, this doesn't work. It seems, that the entity manager tries to execute the statement as follows
INSERT INTO
Play
(user*id
,room*id
) VALUES ('1', '32')which is of course wrong. It should be
INSERT INTO
Play
(user*id
,room*id
) VALUES (1, 32)The text was updated successfully, but these errors were encountered: