Skip to content

DDC-1436: Problems with identity map on self-referencing #2062

Closed
doctrinebot opened this Issue Oct 18, 2011 · 9 comments

2 participants

@doctrinebot

Jira issue originally created by user koc:

/****
 * @Orm\Entity
 * @Orm\Table(name="tt_content")
 */
class Page
{
    /****
     * @Orm\Id
     * @Orm\GeneratedValue
     * @Orm\Column(type="integer", name="id")
     */
    protected $id;

    /****
     * @Orm\ManyToOne(targetEntity="Page", inversedBy="children")
     * @Orm\JoinColumn(name="pid", referencedColumnName="id")
     */
    protected $parent;

    /*** @Orm\OneToMany(targetEntity="Page", mappedBy="parent") **/
    protected $children;

    /*** @Orm\Column(name="page_title") **/
    protected $title;
}

$id = 5;

// step 1 
$page = $this
    ->getEntityManager('read')
    ->createQuery('
        SELECT p, parent
        FROM OloloContentBundle:Page p
            LEFT JOIN p.parent parent
        WHERE p.id = :id
    ')
    ->setParameter('id', $id)
    ->getOneOrNullResult();

// step 2
$page = $this->getEntityManager('read')->find('OloloContentBundle:Page', $id);
var_dump($page->getParent()->getParent()); // expected instance of Page, but got null

When I added one more fetch join for parent then I got Page.

@doctrinebot

Comment created by @beberlei:

Can you test against master again? I made a fix in context of DDC-1452 that i think could solve this issue.

@doctrinebot

Comment created by koc:

I will do it

@doctrinebot

Comment created by koc:

I cann't run master branch on current env (Symfony 2.0.2).

MappingException: The association mapping 'eventArea' misses the 'targetEntity' attribute, but targetEntity present. Can you merge fix into 2.1.x branch?

@doctrinebot

Comment created by @beberlei:

I am not sure this fix is mergable in 2.1, also it is a rather complex change that i don't want to merge back to the stable branch for stability reasons.

Let me try to reproduce this in a test and then go further from there.

@doctrinebot

Comment created by @beberlei:

DDC-1452 is indeed the same bug as this one and the fix works.

@doctrinebot

Comment created by @beberlei:

I cant merge this as with the latest refactorings it gives hundrets of conflicts, but will re-apply manually.

@doctrinebot

Comment created by @beberlei:

Backported and fixed in 2.1.x

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot

Comment created by koc:

Thank you very much, Benjamin!

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.1.3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.