DDC-967: Single Table Inheritance, problem when try create db schema. #1207

Closed
opened 2026-01-22 13:05:58 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 1, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user alexshelkov:

If you have code grouped like this:


/****
- @Entity
  */
  class A extends Z
  {

}


****
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"z" = "Z", "a" = "A"})
 */
class Z
{
    /****
     * @Id
     * @Column(type="integer")
     * @GeneratedValue
     *
     * @var Integer
     */
    protected $id;
}

And then try use console tools to create db schema, you will see the strange errors:

PHP Fatal error:  Class 'Divorcee\Z' not found in /Users/san/Sites/work/doctrine-orm/Divorcee/A.php on line 8
PHP Stack trace:
PHP   1. {main}() /Users/san/Sites/work/doctrine-orm/bin/doctrine:0
PHP   2. include() /Users/san/Sites/work/doctrine-orm/bin/doctrine:4
PHP   3. Doctrine\ORM\Tools\Console\ConsoleRunner::run() /Users/san/Sites/work/doctrine-orm/bin/doctrine.php:52
PHP   4. Symfony\Component\Console\Application->run() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Tools/Console/ConsoleRunner.php:39
PHP   5. Symfony\Component\Console\Application->doRun() /Users/san/Sites/work/doctrine-orm/Doctrine/Symfony/Component/Console/Application.php:113
PHP   6. Symfony\Component\Console\Command\Command->run() /Users/san/Sites/work/doctrine-orm/Doctrine/Symfony/Component/Console/Application.php:187
PHP   7. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() /Users/san/Sites/work/doctrine-orm/Doctrine/Symfony/Component/Console/Command/Command.php:150
PHP   8. Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:53
PHP   9. Doctrine\ORM\Mapping\Driver\AnnotationDriver->getAllClassNames() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Mapping/ClassMetadataFactory.php:122
PHP  10. require_once() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:454

I am not sure, but possibly that happens because of Doctrine try to process "A-entity" before "Z-entity" (because files in directory sorted alphabetically). If I use other file name for example "Zz" instead of "A" (so it will be Zz.php file) all works perfectly.

Originally created by @doctrinebot on GitHub (Jan 1, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user alexshelkov: If you have code grouped like this: ```namespace Divorcee; /**** - @Entity */ class A extends Z { } `````` ```namespace Divorcee; **** * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"z" = "Z", "a" = "A"}) */ class Z { /**** * @Id * @Column(type="integer") * @GeneratedValue * * @var Integer */ protected $id; } `````` And then try use console tools to create db schema, you will see the strange errors: ```./doctrine orm:schema-tool:create PHP Fatal error: Class 'Divorcee\Z' not found in /Users/san/Sites/work/doctrine-orm/Divorcee/A.php on line 8 PHP Stack trace: PHP 1. {main}() /Users/san/Sites/work/doctrine-orm/bin/doctrine:0 PHP 2. include() /Users/san/Sites/work/doctrine-orm/bin/doctrine:4 PHP 3. Doctrine\ORM\Tools\Console\ConsoleRunner::run() /Users/san/Sites/work/doctrine-orm/bin/doctrine.php:52 PHP 4. Symfony\Component\Console\Application->run() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Tools/Console/ConsoleRunner.php:39 PHP 5. Symfony\Component\Console\Application->doRun() /Users/san/Sites/work/doctrine-orm/Doctrine/Symfony/Component/Console/Application.php:113 PHP 6. Symfony\Component\Console\Command\Command->run() /Users/san/Sites/work/doctrine-orm/Doctrine/Symfony/Component/Console/Application.php:187 PHP 7. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() /Users/san/Sites/work/doctrine-orm/Doctrine/Symfony/Component/Console/Command/Command.php:150 PHP 8. Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:53 PHP 9. Doctrine\ORM\Mapping\Driver\AnnotationDriver->getAllClassNames() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Mapping/ClassMetadataFactory.php:122 PHP 10. require_once() /Users/san/Sites/work/doctrine-orm/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:454 ``` I am not sure, but possibly that happens because of Doctrine try to process "A-entity" before "Z-entity" (because files in directory sorted alphabetically). If I use other file name for example "Zz" instead of "A" (so it will be Zz.php file) all works perfectly. ```
admin added the Bug label 2026-01-22 13:05:58 +01:00
admin closed this issue 2026-01-22 13:06:00 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2011):

Comment created by @beberlei:

have you registered an autoloader for your Divorcee namespace? It seems not

$loader = new Doctrine\Common\ClassLoader("Divorcee", "/path");
@doctrinebot commented on GitHub (Jan 2, 2011): Comment created by @beberlei: have you registered an autoloader for your Divorcee namespace? It seems not ``` $loader = new Doctrine\Common\ClassLoader("Divorcee", "/path"); ```
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2011):

Comment created by alexshelkov:

Yes, you are absolutely right, I forget about registering autoloader. I am sorry for false report. Thank for you help.

@doctrinebot commented on GitHub (Jan 2, 2011): Comment created by alexshelkov: Yes, you are absolutely right, I forget about registering autoloader. I am sorry for false report. Thank for you help.
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2011):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jan 2, 2011): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1207