2012-09-14 60 views
0

我之前也发布了这个问题,我再次发布它,因为它尚未解决多个实体管理

我使用的Symfony2我的申请,我需要建立两个数据库连接,即读,写操作此我搜索,轻松地发现,我们可以创建不同的实体管理器和我创建这样的:

我parameters.ini文件 http://dpaste.com/hold/800957/

我config.yml文件 http://dpaste.com/hold/800954/

我的用户实体类 http://dpaste.com/hold/800963/

我跟随实体类: http://dpaste.com/hold/800964/

在控制器使物体

$emWrite = $this->getDoctrine()->getEntityManager('write'); 
$em = $this->getDoctrine()->getEntityManager(); 

当我坚持的实体它给了我下面的错误:

A new entity was found through the relationship ' 
AppBundle\Entity\Follower#user' that was not configured to cascade persist 
operations for entity: adeel. Explicitly persist the new entity or configure 
cascading persist operations on the relationship. If you cannot find out which 
entity causes the problem implement AppBundle\Entity\User#__toString() 
to get a clue. (500 Internal Server Error) 

please hel p我详细,因为这对我来说是创造出巨大的问题......正如我已经尝试过想放弃的参与实体双方坚持房地产这么多的事情......

请帮我....

回答

0

您的问题与多个实体经理无关,而是涉及您尚未设置到您的班级的选项,这是前面的关系目的。

我对你的实体没有太大的细节,但我可以建议你修改以这种方式

<?php 
class User 
{ 
    //... 
    /** 
    * Bidirectional - One-To-Many (INVERSE SIDE) 
    * 
    * @OneToMany(targetEntity="Comment", mappedBy="author", 
        cascade={"persist","remove"}) 
    */ 
    private $commentsAuthored; 
    //... 
} 

关系,其中cascade={"persist","remove"}是你在找什么。

+0

我也在分享我的实体,但我已经试过这个,但它没有工作... –

+0

@MuhammadUmair我想在两个实体管理器之间共享实体并不是一个好的选择,你不能做类似于坚持到的东西级联行动.... – DonCallisto

+0

我已编辑我的问题,并给实体详细信息,请检查它并详细说明你的答案,因为我是新手... –