Thi*_*aut 9 multiple-inheritance mappedsuperclass symfony doctrine-orm
在Symfony2应用程序中,我有一个MainBundle和不同的包,可以启用或不启用.在MainBundle中,我需要拥有模型和基本实体.在OtherBundle的实体具有比相同的表名实体中MainBundle.
MainBundle中的夹具需要加载或不加载MainBundle以外的其他捆绑:
MainBundle
- Model
- Entity (Table name "test")
- Fixtures
OtherBundle
- Entity (Table name "test")
- Fixtures
OtherBundle2
- Entity (Table name="test")
- Fixtures
Run Code Online (Sandbox Code Playgroud)
如果我使用的@ORM\MappedSuperclass的模型,一个@ORM \实体的实体在MainBundle和@ORM \实体在OtherBundle然后Doctrine2停止与错误"表已经存在".
我不能使用继承表,因为我的模型不需要知道其他包中的其他实体.该@ORM\DiscriminatorMap着点OtherBundle.
有没有办法做到这一点 ?
正如 Jasper N. Brouwer 所提到的,它本质上是相同的实体和相同的表,所以做你想做的事情是没有意义的。
在名为“SharedEntityBundle”的捆绑包中创建您的实体,并使用resolve_target_entity从其他捆绑包中关联该实体,而无需他们互相了解。
http://symfony.com/doc/current/cookbook/doctrine/resolve_target_entity.html
话虽这么说,似乎有一个具有多个实体管理器的解决方案: Symfony 2 / Doctrine 2:同一个表的两个实体,使用一个实体来支持另一个实体
| 归档时间: |
|
| 查看次数: |
6333 次 |
| 最近记录: |