Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:49:24+00:00 2026-05-24T16:49:24+00:00

I am using Doctrine 2 MongoDB ODM , all working fine except 1 specific

  • 0

I am using Doctrine 2 MongoDB ODM, 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

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;

used in Project\Entities\PlayerCharacter (extends Project\Entities\World\Object mentioned above)
=>

namespace Project\Entities;

/**
 * @Document(collection="worlds")
 * @HasLifecycleCallbacks
 */
class World {
    /**
 * @ReferenceMany(targetDocument="PlayerCharacter")
 * @var ArrayCollection
 */
protected $playerCharacters;
}

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 (die 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

On the other hand

class PlayerCharacter {
/**
 * @ReferenceOne(targetDocument="User")
 * @var User
 */
protected $user;
 }

=>

/**
 * @Document(collection="users")
 * @HasLifecycleCallbacks
 */
class User {
    /**
     * @ReferenceMany(targetDocument="PlayerCharacter")
     * @var ArrayCollection
     */
    protected $characters;
}

works

In simplified version:
– PlayerCharacter::$user <==(1:N)==> User::$characters
(and all others) are fine, while only
– PlayerCharacter::$world <==(1:N)==> World::$playerCharacters
works only on the World side

Looking at it many days, can’t find anything different.

  • Tried renaming property names, no change
  • Hydrator entry for character—>world looks identically to others
  • When I add the entry semi-manually (via RockMongo), it works fine
  • Creating the “world” field as NULL makes no difference, with {} it says “Undefined index: $id”, but I guess that’s an expected behaviour
  • Entities separately work very fine too, it really just is this one relation

Is there anything I am missing/overlooked or what can I do to discover why is it not getting persisted

(will edit the post if there’s need for more info)

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:49:25+00:00Added an answer on May 24, 2026 at 4:49 pm

    Ok, the thing was there were many entries in the UoW some containing World => null and some World => …WorldProxy, so the latter probably got overwritten

    Using flush() before the assignment solved this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using Doctrine PHP If I have a user with a many to many relationship
Using Doctrine in symfony 1.4 I have several boolean columns defined (stored as a
im using doctrine-project and i have 3 tables table 1: post -------------- postid ,
I am using Doctrine ORM for php and Zend MVC. I have a mysql
I'm using Doctrine 1.2 as my ORM for a Zend Framework Project. I have
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C#, I need a class called User that has a username, password, active
Using Doctrine , I am trying to delete records in a single table based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.