Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with persisting specific relation with Doctrine2 ODM
    primarykey
    data
    text
    <p>I am using <strong>Doctrine 2 MongoDB ODM</strong>, all working fine except 1 specific relation. What's obscure is that I have seemingly identical relations in the project and they all work just fine</p> <pre><code>namespace Project\Entities\World; // same NS as class, but this is after // splitting functionality from Entity to MappedSuperclass, didn't work either /** * @ReferenceOne(targetDocument="Project\Entities\World") * @var IWorld */ protected $world; </code></pre> <p>used in Project\Entities\PlayerCharacter (<strong>extends</strong> Project\Entities\World\Object mentioned above) => </p> <pre><code>namespace Project\Entities; /** * @Document(collection="worlds") * @HasLifecycleCallbacks */ class World { /** * @ReferenceMany(targetDocument="PlayerCharacter") * @var ArrayCollection */ protected $playerCharacters; } </code></pre> <p>When I set the $world variable, it's fine in the PHP script. Even $objectManager->refresh($character), $character->getWorld() === $world turns out fine. But it does never appear in the database itself (<strong>die</strong> right after setting it and flush to make sure it is never changed by accident somewhere) on the PlayerCharacter's end, only on the World side</p> <p>On the other hand</p> <pre><code>class PlayerCharacter { /** * @ReferenceOne(targetDocument="User") * @var User */ protected $user; } </code></pre> <p>=></p> <pre><code>/** * @Document(collection="users") * @HasLifecycleCallbacks */ class User { /** * @ReferenceMany(targetDocument="PlayerCharacter") * @var ArrayCollection */ protected $characters; } </code></pre> <p>works</p> <p>In simplified version:<br> - PlayerCharacter::$user &lt;==(1:N)==> User::$characters<br> (and all others) are fine, while only<br> - PlayerCharacter::$world &lt;==(1:N)==> World::$playerCharacters<br> works only on the World side</p> <p>Looking at it many days, can't find anything different.</p> <ul> <li>Tried renaming property names, no change </li> <li>Hydrator entry for character--->world looks identically to others </li> <li>When I add the entry semi-manually (via RockMongo), it works fine </li> <li>Creating the "world" field as NULL makes no difference, with {} it says "Undefined index: $id", but I guess that's an expected behaviour</li> <li>Entities separately work very fine too, it really just is this one relation</li> </ul> <p>Is there anything I am missing/overlooked or what can I do to discover why is it not getting persisted</p> <p>(will edit the post if there's need for more info)</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload