2

I have a small question about doctrine and Symfony 2:

Is it possible to declare a relation (OneToMany) between two entities which are managed by two different entity managers (and two different DB connections) ?

To be more precise, I have two bundles :

  • FpnABundle -> Mapped with A_database (and A_entitymanager)
  • FpnBBundle -> Mapped with B_database (and B_entitymanager)

And I need to define an association between FpnABundle:User and FpnBBundle:Post

If I try to do that, when I perform a DB schema update, I have the following error :

The class 'Fpn\ABundle\Entity\User' was not found in the chain configured namespaces Fpn\BBundle\Entity

Thanks for your help!

Baurelien
  • 21
  • 1
  • possible duplicate of [Issues in entities from different bundles using different entity managers](http://stackoverflow.com/questions/9330018/issues-in-entities-from-different-bundles-using-different-entity-managers) – David G Jan 19 '13 at 03:09

1 Answers1

2

Basically, the answer is no.

You will probably need to do this: http://symfony.com/doc/current/cookbook/doctrine/resolve_target_entity.html

Even with this it will only work if the two databases are on the same server. And at some point you will probably need to add the schema name to the the table name. Somewhat painful.

Cerad
  • 48,157
  • 8
  • 90
  • 92