DDC-1664: Doctrine2 ails to manage multiple connections and relationships between different symfony bundles #2090

Closed
opened 2026-01-22 13:40:24 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 21, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user sibok:

EDIT: Assetic has changed its path, so you can remove assetic tags from app/config/config.yml and app/config/config_dev.yml to get rid of the error.

LINK: http://www.2shared.com/file/2u4GhFVX/SymfonyTestCasetar.html

If you download the tar.gz file you could see there is a FooBundle and a BarBundle, each one using its own connection an of course each own entity manager. Inside FooBundle there is Foo entity and inside Bar Bundle there is Bar entity, each one has each fixture to load some info to the database. The issue i'm talking about appears here when trying to load the fixtures.

****First i create both databases, each one using each own entity manager so also using each own connection:
php ./symfony doctrine:database:drop --connection="bar" --force'
php ./symfony doctrine:database:drop --connection="foo" --force'
php ./symfony doctrine:database:create --connection="bar"
php ./symfony doctrine:database:create --connection="foo"

****Then i successfully create the schema:
php ./symfony doctrine:schema:create --em="bar"
php ./symfony doctrine:schema:create --em="foo"

****And finally i try to load the fixtures which throughs me an error:
php ./symfony doctrine:fixtures:load --em="foo"
php ./symfony doctrine:fixtures:load --em="bar"

****That's the error i get, so i think Symfony has some kind of bug:
Created database for connection named bar
Created database for connection named foo
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...
Database schema created successfully!
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...
Database schema created successfully!

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_
loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_

[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class.

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_
[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myFooBundleBundle\Entity\Foo is not a valid entity or mapped super class.

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

****But if i randomly remove a fixture, no matter which one, everything runs fine:
mv src/myVendor/myBarBundleBundle/DataFixtures/ORM/Bar.php /tmp/
php ./symfony doctrine:fixtures:load --em="foo"

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo

****But when both fixtures exists:
mv /tmp/Bar.php src/myVendor/myBarBundleBundle/DataFixtures/ORM/
php ./symfony doctrine:fixtures:load --em="foo"

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo
loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_

[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class.

Originally created by @doctrinebot on GitHub (Feb 21, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user sibok: EDIT: Assetic has changed its path, so you can remove assetic tags from app/config/config.yml and app/config/config_dev.yml to get rid of the error. LINK: http://www.2shared.com/file/2u4GhFVX/SymfonyTestCasetar.html If you download the tar.gz file you could see there is a FooBundle and a BarBundle, each one using its own connection an of course each own entity manager. Inside FooBundle there is Foo entity and inside Bar Bundle there is Bar entity, each one has each fixture to load some info to the database. The issue i'm talking about appears here when trying to load the fixtures. ****First i create both databases, each one using each own entity manager so also using each own connection: php ./symfony doctrine:database:drop --connection="bar" --force' php ./symfony doctrine:database:drop --connection="foo" --force' php ./symfony doctrine:database:create --connection="bar" php ./symfony doctrine:database:create --connection="foo" ****Then i successfully create the schema: php ./symfony doctrine:schema:create --em="bar" php ./symfony doctrine:schema:create --em="foo" ****And finally i try to load the fixtures which throughs me an error: php ./symfony doctrine:fixtures:load --em="foo" php ./symfony doctrine:fixtures:load --em="bar" ****That's the error i get, so i think Symfony has some kind of bug: Created database for connection named bar Created database for connection named foo ATTENTION: This operation should not be executed in a production environment. Creating database schema... Database schema created successfully! ATTENTION: This operation should not be executed in a production environment. Creating database schema... Database schema created successfully! > purging database > loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_ > loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_ [Doctrine\ORM\Mapping\MappingException] Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class. doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate] purging database loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_ [Doctrine\ORM\Mapping\MappingException] Class myVendor\myFooBundleBundle\Entity\Foo is not a valid entity or mapped super class. doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate] ****But if i randomly remove a fixture, no matter which one, everything runs fine: mv src/myVendor/myBarBundleBundle/DataFixtures/ORM/Bar.php /tmp/ php ./symfony doctrine:fixtures:load --em="foo" > purging database > loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo ****But when both fixtures exists: mv /tmp/Bar.php src/myVendor/myBarBundleBundle/DataFixtures/ORM/ php ./symfony doctrine:fixtures:load --em="foo" > purging database > loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo > loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_ [Doctrine\ORM\Mapping\MappingException] Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class.
admin added the Bug label 2026-01-22 13:40:24 +01:00
admin closed this issue 2026-01-22 13:40:25 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 3, 2012):

Comment created by @beberlei:

If you have multiple connections you have to use --fixtures-dir to point as an argument to doctrine:fixtures:load to point to only the fixtures for the connection you use.

Fixtures are not specified to a specific connection, so just calling "fixtures:load" will try to load both fixtures with the specified connection, which is obviously not working for the reasons you described.

@doctrinebot commented on GitHub (Mar 3, 2012): Comment created by @beberlei: If you have multiple connections you have to use --fixtures-dir to point as an argument to doctrine:fixtures:load to point to only the fixtures for the connection you use. Fixtures are not specified to a specific connection, so just calling "fixtures:load" will try to load both fixtures with the specified connection, which is obviously not working for the reasons you described.
Author
Owner

@doctrinebot commented on GitHub (Mar 3, 2012):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Mar 3, 2012): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2090