Hello,

I've run into some trouble while trying to use "NOTIFY" change tracking 
policy with embedded entities.. It seems that embedded entities do not 
receive 'propertyChanged' listeners thus their changed value is never 
persisted to database.
Example:


/**
 * @\Doctrine\ORM\Mapping\Embeddable()
 * @\Doctrine\ORM\Mapping\ChangeTrackingPolicy("NOTIFY")
 */
class Status implements \Doctrine\Common\NotifyPropertyChanged
{
    /**
     * @var \Doctrine\Common\PropertyChangedListener[]
     */
    protected $listeners = [];

    // ... class properties

    protected $code;

    public function addPropertyChangedListener(\Doctrine\Common\
PropertyChangedListener $listener)
    {
        $this->listeners[] = $listener;
    }

    public function setCode($code)
    {
        if ($this->code !== $code) {
            // notify
            foreach ($this->listeners as $listener) {
                $listener->propertyChanged($this, 'code', $this->code, $code
);
            }
            // set value
            $this->code = $code;
        }
    }

    // ... getters, setters
}


/**
 * @\Doctrine\ORM\Mapping\Entity()
 * @\Doctrine\ORM\Mapping\ChangeTrackingPolicy("NOTIFY")
 */
class Match implements \Doctrine\Common\NotifyPropertyChanged
{
    protected $listeners = [];

    /**
     * @\Doctrine\ORM\Mapping\Embedded(class="Status")
     */
    protected $status;

    public function addPropertyChangedListener(\Doctrine\Common\
PropertyChangedListener $listener)
    {
        $this->listeners[] = $listener;
    }

    public function getStatus(){
        return $this->status;
    }

    // ... getters, setter
}


/** @var Match $match */
$match = $matchRepository->findOneBy(/* ..some condition.. */);
$match->getStatus()->setCode(22);

$manager->flush(); // no change


Was this intended or it's a bug ?

I've tried to pull a workaround for this by forwarding listeners to 
embedded object from its parent on postLoad life cycle event, but even 
though listeners get called there are still no changes to the database.. 

Any help is highly appreciated :)


Best regards,
Miro

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to