[DDC-1105] Unable to persist entities implemented using Class Table Inheritance(CTI) strategy across multiple database tables Created: 07/Apr/11 Updated: 01/May/11 Resolved: 01/May/11
|Project:||Doctrine 2 - ORM|
|Reporter:||Ire Ogunsina||Assignee:||Benjamin Eberlei|
zend framework, Doctrine 2, Apache, MySQL, Windows
I have 2 classes, a Parent class, Person and a Child class Employee using Class Table Inheritance mapping strategy. The classes' corresponding tables exist in 2 separate database: Person table exists in database: dbOne and Employee table is in dbTwo.
The classes are like:
CREATE TABLE Employee (
where the reference table name is prefixed with the database name.
The main problem is that when I call
On Person object, it flags an error:
Message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbOne.Employee' doesn't exist . Apparently, the expectation is for the base class to persist its instance and be able to automatically persist the sub class as well. This problem is absent when the tables are in the same database- which indicates that the CTI structure expects the entity tables to be within the same database. The reverse is true if I call the entity manager (for dbTwo) to save an Employee object.
Is there a workaround for this bug/feature?
|Comment by Ire Ogunsina [ 07/Apr/11 ]|
It appears that ORM technologies are limited in their ability to generate SQL queries that interrogate multiple databases in a single SQL statement (unit of work). This largely may be due to the fact that the entity manager is restricted to one database. This limitation may be responsible for this behavior.
|Comment by Benjamin Eberlei [ 01/May/11 ]|
Yes, the EntityManager is focused on one database, not multiple.
There are two workarounds: