Details
-
Type:
Documentation
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0
-
Fix Version/s: None
-
Component/s: Documentation
-
Security Level: All
-
Labels:None
Description
If you need to override the ID Generator, e.g. during a migration, you can do that in your migration script as follows:
Overriding the ID generator
$em->getClassMetadata('foo\bar\Entity')->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
$em->getClassMetadata('foo\bar\Entity')->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE'));
Make sure that both calls equal to the same generator type. You can now modify the @Id fields in your entities. Additionally, make sure that you set the IdGenerator after you created the database using e.g. SchemaTool->create().
Never mind. I've upgraded to Doctrine 2.3.0 and it works as expected.