DDC-245: Inheritance Breaks When Child Has No Table #303

Closed
opened 2026-01-22 12:33:58 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 7, 2010).

Jira issue originally created by user mridgway:

I have a class hierarchy where the the super class uses SINGLE_TABLE inheritance:

Example:

/*
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="type", type="string")
 * @DiscriminatorMap({"Static"="StaticBlock", "Test"="Test"})
*/
abstract class Block
{
    /****
     * @Id @Column(name="id", type="integer")
     * @GeneratedValue(strategy="AUTO")
     */
    protected $id;
//...
abstract class DynamicBlock extends Block
{
//... No doctrine properties
}
/*
 * @Entity
 */
class Test extends DynamicBlock
{
//... No doctrine properties
}

CreateSchema runs without error and creates the tables that I would want (Block table but no DynamicBlock table and no Test table). I am then able to persist new objects of type Test, but when I try to load one again I get "Base table or view not found: 1146 Table 'db.dynamic' doesn't exist".

I'm not sure if it should be creating that table (which I wouldn't want personally) or if there's a bug when it goes to load these objects. It looks like there is some inconsistency in how this is handled.

Originally created by @doctrinebot on GitHub (Jan 7, 2010). Jira issue originally created by user mridgway: I have a class hierarchy where the the super class uses SINGLE_TABLE inheritance: Example: ``` none /* * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="type", type="string") * @DiscriminatorMap({"Static"="StaticBlock", "Test"="Test"}) */ abstract class Block { /**** * @Id @Column(name="id", type="integer") * @GeneratedValue(strategy="AUTO") */ protected $id; //... ``` ``` none abstract class DynamicBlock extends Block { //... No doctrine properties } ``` ``` none /* * @Entity */ class Test extends DynamicBlock { //... No doctrine properties } ``` CreateSchema runs without error and creates the tables that I would want (Block table but no DynamicBlock table and no Test table). I am then able to persist new objects of type Test, but when I try to load one again I get "Base table or view not found: 1146 Table 'db.dynamic' doesn't exist". I'm not sure if it should be creating that table (which I wouldn't want personally) or if there's a bug when it goes to load these objects. It looks like there is some inconsistency in how this is handled.
admin added the Bug label 2026-01-22 12:33:58 +01:00
admin closed this issue 2026-01-22 12:33:59 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 7, 2010):

Comment created by romanb:

Attached a test case that works flawlessly. Please take a look and let me know.

@doctrinebot commented on GitHub (Jan 7, 2010): Comment created by romanb: Attached a test case that works flawlessly. Please take a look and let me know.
Author
Owner

@doctrinebot commented on GitHub (Jan 8, 2010):

Comment created by mridgway:

Turned out to be a lingering discriminator in another class.

@doctrinebot commented on GitHub (Jan 8, 2010): Comment created by mridgway: Turned out to be a lingering discriminator in another class.
Author
Owner

@doctrinebot commented on GitHub (Jan 8, 2010):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jan 8, 2010): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/28aa54b8b1b0bbd585df

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/28aa54b8b1b0bbd585df - [10273_DDC245Test.php](https://gist.github.com/28aa54b8b1b0bbd585df#file-10273_DDC245Test-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#303