Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1942

problem with serialize/merging entities with aggregation

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: ORM
    • Labels:
    • Environment:
      linux, php 5.4.4, apache 2.2.22, mysql 5.5

      Description

      i have these two entities:

      namespace nuevo_paquete;

      class Clase_01{
      	/**
      	* @Id
      	* @Column(name="id",type="integer",nullable=false)
      	* @GeneratedValue
      	*/
      	protected $id;
              
              /**
      	* @ManyToOne(targetEntity="\paquete_02\Clase_03", inversedBy="clase_01", fetch="EXTRA_LAZY", cascade={"detach","merge"})
      	* @JoinColumn(name="clase_03", referencedColumnName="id")
      	*/
      	protected $clase_03;
      
              /**
      	* @ManyToOne(targetEntity="\paquete_02\Clase_03", inversedBy="clase_01_1", fetch="EXTRA_LAZY", cascade={"detach","merge"})
      	* @JoinColumn(name="clase_03_1", referencedColumnName="id")
      	*/
      	protected $clase_03_1;
      }
      
      namespace paquete_02;
      class Clase_03{
         /**
      	* @Id
      	* @Column(name="id",type="integer",nullable=false)
      	* @GeneratedValue
      	*/
      	protected $id;
      
              /**
      	* @OneToMany(targetEntity="\nuevo_paquete\Clase_01", mappedBy="clase_03", fetch="EXTRA_LAZY", cascade={"detach"})
      	*/
      	protected $clase_01;
      	
      	/**
      	* @OneToMany(targetEntity="\nuevo_paquete\Clase_01", mappedBy="clase_03_1", fetch="EXTRA_LAZY", cascade={"detach"})
      	*/
      	protected $clase_01_1;
      }
      

      Clase_01 have two aggregation association with Clase_03

      Clase_01 ------> Clase_03

      -----> Clase_03_1

      when serialize an object of class Clase_01 and then unserialize, i lost the reference to the object of class Clase_03
      but i can see Clase_03_1

      ej:

      $aux_orm = $em->find('nuevo_paquete\Clase_01', 1);
      $em->detach($aux_orm);
      $aux_s = serialize($aux_orm);
      $aux_orm = unserialize($aux_s);
      
      $aux_orm = $em->merge($aux_orm);
      echo '['.$aux_orm->getId().']'; // [1]
      echo '['.$aux_orm->getClase_03()->getId().']'; // [] expected : [1]
      echo '['.$aux_orm->getClase_03_1()->getId().']'; // [1]
      

      when i call get_clase_03() before detach the object, i can see the object Clase_03
      ej:

      $aux_orm = $em->find('nuevo_paquete\Clase_01', 1);
      $aux_orm->getClase_03()->getId();
      
      $em->detach($aux_orm);
      $aux_s = serialize($aux_orm);
      $aux_orm = unserialize($aux_s);
      
      $aux_orm = $em->merge($aux_orm);
      echo '['.$aux_orm->getId().']'; // [1]
      echo '['.$aux_orm->getClase_03()->getId().']'; // [1]
      echo '['.$aux_orm->getClase_03_1()->getId().']'; // [1]
      

        Activity

        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-1172] was assigned:
        https://github.com/doctrine/doctrine2/pull/1172

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-1172] was assigned: https://github.com/doctrine/doctrine2/pull/1172
        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-585] was closed:
        https://github.com/doctrine/dbal/pull/585

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-585] was closed: https://github.com/doctrine/dbal/pull/585
        Hide
        Marco Pivetta added a comment -

        This issue is valid only before the fix introduced at DDC-2306. Duplicate confirmed

        Show
        Marco Pivetta added a comment - This issue is valid only before the fix introduced at DDC-2306 . Duplicate confirmed
        Hide
        Benjamin Eberlei added a comment -

        A related Github Pull-Request [GH-585] was closed
        https://github.com/doctrine/doctrine2/pull/585

        Show
        Benjamin Eberlei added a comment - A related Github Pull-Request [GH-585] was closed https://github.com/doctrine/doctrine2/pull/585
        Hide
        Marco Pivetta added a comment -

        This may be a duplicate of DDC-2306

        Show
        Marco Pivetta added a comment - This may be a duplicate of DDC-2306

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            gabriel sancho
          • Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: