Hi,
sorry, after there was no response to my question I did not look into the
matter anymore.. And since it was so long ago I don't remember if I managed
to overcome this or did not use NOTIFY policy at all.
Sorry for not being of much help :(
Best regards,
Miroslav
On Tuesday, July 5, 2016 at 9:55:48 AM UTC+2, Holtkamp wrote:
>
> Hi Miro,
>
> what are your findings? I encountered your question when I noticed that
> lifecycle-events (postLoad, etc) seem not to be supported for Embeddables.
>
> Can somebody confirm this?
>
> Cheers,
>
> Menno
>
> On Friday, 24 April 2015 11:27:02 UTC+2, Miroslav Braun wrote:
>>
>> 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 https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.