原则 2:无法让 LifecycleCallBacks 与单表继承实体一起使用?
是否存在不允许这样做的错误?我已将 LifecycleCallBacks 注释和 prepersist 方法放入基类中(也尝试了子类),但无法让 LifecycleCallBacks 工作。任何意见将不胜感激!谢谢!
/**
* @Entity(repositoryClass="Entity\Repository\EventRepository")
* @HasLifecycleCallbacks
* @Table(name="events")
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="type", type="string")
* @DiscriminatorMap({"phone" = "PhoneEvent", "meeting" = "MeetingEvent"})
*/
class Event implements \ActivityItem{
/** @PrePersist */
public function setComplianceStatus(){...}
}
这不起作用,所以我也尝试过:
/**
* @Entity @HasLifecycleCallbacks
*/
class PhoneEvent extends Event{
/** @PrePersist */
public function setComplianceStatus(){}
}
Is there a bug that doesn't allow this? I've put the LifecycleCallBacks annotation and a prepersist method into the base class (also tried the child classes as well) and can't get LifecycleCallBacks to work. Any input would be greatly appreciated! Thanks!
/**
* @Entity(repositoryClass="Entity\Repository\EventRepository")
* @HasLifecycleCallbacks
* @Table(name="events")
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="type", type="string")
* @DiscriminatorMap({"phone" = "PhoneEvent", "meeting" = "MeetingEvent"})
*/
class Event implements \ActivityItem{
/** @PrePersist */
public function setComplianceStatus(){...}
}
This didn't work, so I also tried:
/**
* @Entity @HasLifecycleCallbacks
*/
class PhoneEvent extends Event{
/** @PrePersist */
public function setComplianceStatus(){}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我用你提出的映射进行了尝试,该星座似乎确实存在问题。
当我这样做时它起作用了:
因为看起来该方法必须存在于父类中,即使它可以声明为抽象的。奇怪,可能是bug。
I tried it with the mapping you proposed and there really seems to be a problem in that constellation.
It worked when I did:
As it seems the method has to be present in the parent class, even though it can be declared as abstract. Strange, might be a bug.