开发者

Doctrine2 lifecycle callbacks in base class?

开发者 https://www.devze.com 2023-04-11 01:19 出处:网络
In Doctrine2 is it possible to invoke lifecycle callbacks in a base class, which all entities inherit from.

In Doctrine2 is it possible to invoke lifecycle callbacks in a base class, which all entities inherit from.

Something like this http://pastie.org/2650901

The problem is that validationCheck() method doesn't get invoked when I persist or update an entity.

Also, I tried making the base class @MappedSuperclass, but then it breaks all further inheritance, and that i开发者_JAVA百科s not an option.


Got it working, my mistake.
Here is the solution, if anyone else stumbles on the same issue.

Base class has to have a @MappedSuperclass and @HasLifecycleCallbacks notation.

Entity class, if uses further inheritance, has to be abstract.

http://pastie.org/2661834

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号