PreUpdate entity symfony LifecycleCallbacks

前端 未结 2 2022
臣服心动
臣服心动 2021-01-26 11:24

I have a little problem with the PreUpdate LifecycleCallbacks in Symfony.

I have an entity User with a OneToMany relation with an entity product.

class U         


        
相关标签:
2条回答
  • 2021-01-26 11:32

    I have got same issue and I have solved it by update $user in preUpdate() then schedule an extra update:

        $args->getEntityManager()->getUnitOfWork()->scheduleExtraUpdate($user, array(
            'field_name' => array($oldValue, $newValue)
        ));
    
    0 讨论(0)
  • 2021-01-26 11:55

    Changing related entities is not allowed using a preUpdate listener.

    Changes to associations of the updated entity are never allowed in this event, since Doctrine cannot guarantee to correctly handle referential integrity at this point of the flush operation.

    ... from the documentation.

    0 讨论(0)
提交回复
热议问题