mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1867: Inserting objects in relation x to one, schedules extra update error #2354
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 (Jun 11, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user moatux:
At the time of persistence (flush operation) of objects with x-to-one relationship, join IDs are positioned correctly but extra updates are planned, which will generate update in database by changing the identifiers that were previously correctly positioned.
scheduled update is performed in the basicEntityPersister then these extra updates are played in the unitOfWork.
To take a simple example, if you have two objects Hotel, Room in one to one relationship (for simplicity)
we then have the following code:
It then creates:
in the SQL log we have:
Persistence has positioned correctly Room.hotel_id = Hotel.id
But an extra update scheduled created this request
To avoid this behavior, i had to comment these lines in the unitOfWork file : (around line 316)
and all works well so.
@doctrinebot commented on GitHub (Jun 11, 2012):
Comment created by moatux:
see DDC-171 key bug
@doctrinebot commented on GitHub (Jul 4, 2012):
Comment created by @beberlei:
fixed styles.
removing a feature is not a fix for something :)
@doctrinebot commented on GitHub (Jul 4, 2012):
Comment created by @beberlei:
Your mapping is wrong, you are not supposed to map both hotel_id and hotel. Just use $hotel and $hotel->getId() with 2.2 its optimized not to do extra lazy load queries.
@doctrinebot commented on GitHub (Jul 4, 2012):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Jul 5, 2012):
Comment created by moatux:
Removing this feature, I knew it was not the best solution but i didn't understand where was the problem.
I wanna say you thanks a lot for your anwser. You re wright, mapping was not correct.
Congratulations for this work, doctrines 2 is an awesome PHP project.
Thank you again.