Open doctrinebot opened 11 years ago
Comment created by rbaarsma:
I have the same issue and it's easy to reproduce with a clean Symfony 2 setup with FOSUserBundle. Once you add
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="usernameCanonical",
* column=@ORM\Column(
* name = "username_canonical",
* type = "string",
* length = 255,
* unique = false
* )
* )
* })
It will properly do doc:schema:update --force But it will fail on doc:gen:entities (YourEntity)
Comment created by waterman:
Not sure I agree this is minor - might not affect many users, but it's pretty blocking if you do run into it. Any ideas on a fix?
Comment created by @ocramius:
[~waterman] you are supposed to manually edit generated entities anyway
Comment created by waterman:
" you are supposed to manually edit generated entities anyway"
This applies to creating new entities as well as adapting old ones. Ie. Once you use an AttributeOverride anywhere in your project, you then cannot use generate:entities anywhere else.
Comment created by @ocramius:
[~waterman] yes, and you are supposed to avoid the generator after the first run.
Comment created by waterman:
You really cannot use the generate:entities command to generate method stubs in ANY of your entities or new entities after the first time you run it??
If this use case works as designed without AttributeOverride in the project, but not with AttributeOverrides, then it's a bug not us doing it wrong.
Comment created by cmodijk:
I agree with [~waterman] that this is a bug if it works al the time and not when you use AttributeOverrides.
Now we just temporary remove the AttributeOverrides and then generate our stubs.
Comment created by cmodijk:
I tried to debug the issue and found that during the gatering of the class metadata you will get the DisconnectedClassMetadataFactory which gives the StaticReflectionService for the getParentClasses it returns an empty array which should be al the parent classes of an entity. Because of this the mapping information of the parent class does not exists and can't be overwritten.
Comment created by cmodijk:
If I implement the following code in the getParentClasses of the StaticReflectionService it work's like a charm
if ( ! class_exists($class)) {
throw MappingException::nonExistingClass($class);
}
return class_parents($class);
Comment created by eschultz:
This bug has been fixed by fixing DDC-1379. If you use protected variables in your base class, the schema is created correctly and the entity generator also does not generate properties twice. When using Symfony2, just set "doctrine/orm" to "2.4@dev" in "composer.json" or wait for an upcoming release.
Jira issue originally created by user jvandesande:
The "orm:generate-entities" command fails when doctrine attribute and/or association overrides are used. So from the moment that you use an attribute/association override, it is implossible to use the generate entities command. I think that the solution to this problem is to ignore the overrides when generating entities.
The exception given in case of an attribute override is (this is executed within a Symfony2 project doctrine:generate:entities):