【问题标题】:A new entity was found through the relationship *** that was not configured to cascade persist operations for entity通过关系 *** 找到了一个新实体,该实体未配置为对实体进行级联持久操作
【发布时间】:2016-11-02 06:44:04
【问题描述】:

我目前正在为一些测试创建一些固定装置,但我遇到了这个错误。你知道如何解决它吗?

我有很多灯具要复制粘贴。

A new entity was found through the relationship '***' that was not configured to cascade persist operations for entity: 
***. To solve this issue: Either explicitly call EntityManager#persist() on     
this unknown entity or configure cascade persist  this association in the 
mapping for example @OneToOne(..,cascade={"persist"}). If you cannot find 
out which entity causes the problem implement '***#__toString()' to get a clue.

【问题讨论】:

    标签: php symfony doctrine-orm copy fixtures


    【解决方案1】:

    该错误表示当前对象中存在尚未保存到数据库的相关实体。您需要确保您的关系设置为级联持久调用(意味着它将自动保存),或者您需要在保存当前实体之前持久保存未保存的实体。

    【讨论】:

    • 我不想实现这个级联功能。而且这个实体是一个已经保存在数据库中的固定装置......所以它已经被持久化了......
    • Paul 是对的,这个错误发生在 entitymanager 未知的实体上。如果您说对象已经保存在数据库中,那么它们大多数都已分离。也许您将它们保存在会话中并在以后的调用中检索它们?
    • @EmanuelOster 这在我的会话中是完全正确的。怎样才能摆脱这个错误的错误?
    猜你喜欢
    • 2015-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多