mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2586: BasicEntityPersister::_insertSql have old cached value, even if classmetadata changes #3245
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 @doctrinebot on GitHub (Aug 2, 2013).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user umed:
BasicEntityPersister caches *insertSql into the *insertSql property field. Its probably good, however I have a problem with it.
My class metadata can changed dynamically, and for example, if entity table has been changed, _insertSql value does not change.
For example, lets say I have such situation:
$entity = new MyEntity('somevalue');
$metadata = $entityManager->getClassMetadata('MyEntity');
$metadata->setPrimaryTable(array('name' => 'myentity_1'));
$entityManager->persist($entity); // here _insertSql is already cached with
myentity_1table name$entityManager->flush();
$entity = new MyEntity('somevalue2');
$metadata = $entityManager->getClassMetadata('MyEntity');
$metadata->setPrimaryTable(array('name' => 'myentity_2'));
$entityManager->persist($entity); // here _insertSql DOES NOT CHANGE, even if class metadata has been changed, because its already cached and does not listens to the class metadata changes
$entityManager->flush();
// and the result I have 2 rows in the same myentity_1 table, but I want to have it in the different tables.
There is no method to clear **insertSql value, and no method to make it know about class metadata changes.
I want to see official solution for this problem