Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.2
    • Fix Version/s: None
    • Component/s: DQL, Mapping Drivers, ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Symfony2

      Description

      Hello,
      I observe a strange behavior of a query result done by DQL (only tested DQL in fact). In the last entry of my result, the joined entity are returned to null

      My tables are:

      Entity1
      /**
       * @ORM\Table(name="entity1")
       * @ORM\Entity()
      **/
      class Entity1
      {	
      	 /**
           * @ORM\Column(name="entity1_id", type="integer")
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
      	protected $entity1_Id; 
      	
      	/**
      	* @ORM\Column(name="entity1_text", type="string")
      	*/
          protected $entity1_Text;
      }
      
      Entity2
      /**
       * @ORM\Table(name="entity2")
       * @ORM\Entity()
      **/
      class Entity2
      {	
              /**
      	* @ORM\OneToOne(targetEntity="Entity1")
      	* @ORM\JoinColumn(name="entity1_id", referencedColumnName="entity1_id")
      	* @ORM\Id
      	*/
      	protected $entity1_id; 
          
      	/**
      	* @ORM\ManyToOne(targetEntity="Entity3")
      	* @ORM\JoinColumn(name="entity3_id", referencedColumnName="entity3_id")
      	*/
      	protected $entity3; 
      }
      
      Entity3
      /**
       * @ORM\Table(name="entity3")
       * @ORM\Entity()
      **/
      class Entity3
      {	
      	 /**
           * @ORM\Column(name="entity3_id", type="integer")
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
      	protected $entity3_Id; 
      	
      	/**
      	* @ORM\Column(name="entity3_text", type="string")
      	*/
          protected $entity3_Text;
      }
      

      So when I do a simple request like this:

      DQL Request
      SELECT ent2, ent3 FROM f4cIndexBundle:Entity2 ent2 JOIN ent2.entity3 ent3
      

      The result is looks like this

      Result NOK
      array (size=2)
        0 => 
          object(f4c\IndexBundle\Entity\Entity2)[550]
            protected 'entity1_id' => 
              object(Proxies\__CG__\f4c\IndexBundle\Entity\Entity1)[502]
                ...
            protected 'entity3' => 
              object(f4c\IndexBundle\Entity\Entity3)[497]
                protected 'entity3_Id' => int 2
                protected 'entity3_Text' => string 'TEXT OF ENTITY 3 - SPECIFIC 2' (length=29)
        1 => 
          object(f4c\IndexBundle\Entity\Entity2)[498]
            protected 'entity1_id' => 
              object(Proxies\__CG__\f4c\IndexBundle\Entity\Entity1)[499]
                ...
           protected 'entity3' => null
      

      The entity3 of the last result is never joined and set to null (it's not possible because of the JOIN no ?)
      I spent to days on this and I observed that when I add a property in my entity 2 like this

      Entity2
      /**
       * @ORM\Table(name="entity2")
       * @ORM\Entity()
      **/
      class Entity2
      {	
          ...
          /**
      	* @ORM\Column(name="entity2_text", type="string")
      	*/
          protected $entity2_Text;
      }
      

      The result is ok

      Result OK
      array (size=2)
        0 => 
          object(f4c\IndexBundle\Entity\Entity2)[550]
            protected 'entity1_id' => 
              object(Proxies\__CG__\f4c\IndexBundle\Entity\Entity1)[498]
               ...
            protected 'entity2_Text' => string 'TEXT2' (length=5)
            protected 'entity3' => 
              object(f4c\IndexBundle\Entity\Entity3)[499]
                protected 'entity3_Id' => int 1
                protected 'entity3_Text' => string 'TEXT OF ENTITY 3 - SPECIFIC 1' (length=29)
        1 => 
          object(f4c\IndexBundle\Entity\Entity2)[494]
            protected 'entity1_id' => 
              object(Proxies\__CG__\f4c\IndexBundle\Entity\Entity1)[495]
                ...
            protected 'entity2_Text' => string 'TEXT1' (length=5)
            protected 'entity3' => 
              object(f4c\IndexBundle\Entity\Entity3)[496]
                protected 'entity3_Id' => int 2
                protected 'entity3_Text' => string 'TEXT OF ENTITY 3 - SPECIFIC 2' (length=29)
      

      Is it normal ? Is this a kwon issue ?

      Thanks for your help

      Raphael P.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Raphael Parazols
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: