Details
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]