mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Multiple tables on single entity (unique schema) #5386
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @PillowPillow on GitHub (Jan 16, 2017).
Originally assigned to: @Ocramius on GitHub.
Hello. We have an issue with our current doctrine setup.
We would like to map a unique entity to multiple generated tables.
I know that's not a standard usage but our constraint necessitate some optimizations and we need to split our tables by account.
We tried to update the repository table name by calling setPrimaryTable on the classMetadata property before each queries. However, it seems that we can't update the table after the first execution.
Working example :
Problematic case :
Is there a proper solution to handle this case to be compliant with the doctrine philosophy? Is it at least possible?
We saw an other "solution" digging into the Gidmo code, using the AST walkers but that can only handle the select cases, not the other CRUD operations.
Thanks for your attention.
Best regards
Nicolas
@Ocramius commented on GitHub (Jan 17, 2017):
Modifying metadata at runtime is simply not supported, as the metadata details may be cached within the various ORM components.
You may, though, create multiple metadata instances, each for a different class/interface, and then make the reflection details point at a single class.
This will still fail to correctly work with managed instances though.
Closing as
can't fix.@bululu commented on GitHub (May 14, 2018):
Hello,
I had the same problem and i was able to workaround it with $em->clear();
to clear the cache so the table would refresh
//...
$em = $this->getDoctrine()->getManager();
$productM = $em->getRepository('DataBundle:Product');
$classMetaData = $em->getClassMetadata('DataBundle:Product');