Exception when inserting a joined subclass #6302

Closed
opened 2026-01-22 15:30:26 +01:00 by admin · 2 comments
Owner

Originally created by @andrews05 on GitHub (Sep 22, 2019).

Bug Report

Q A
BC Break don't know
Version 3.0-dev

Summary

When persisting a new entity of a joined subclass, an exception will be thrown if the subclass has defined any properties that are not columns.

Current behavior

The following exception will be thrown:
Call to undefined method Doctrine\ORM\Mapping\TransientMetadata::getColumnName() in Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php on line 468

How to reproduce

/**
 * @ORM\Entity
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorMap({"child" = "Child"})
 */
abstract class Main {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;
}

/**
 * @ORM\Entity
 */
class Child extends Main {
    private $someProperty; // Not a column
}

$child = new Child();
$em->persist($child);
$em->flush();

Expected behavior

Successful insert with no exception.

Originally created by @andrews05 on GitHub (Sep 22, 2019). ### Bug Report | Q | A |------------ | ------ | BC Break | don't know | Version | 3.0-dev #### Summary When persisting a new entity of a joined subclass, an exception will be thrown if the subclass has defined any properties that are not columns. #### Current behavior The following exception will be thrown: `Call to undefined method Doctrine\ORM\Mapping\TransientMetadata::getColumnName() in Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php on line 468` #### How to reproduce ```PHP /** * @ORM\Entity * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorMap({"child" = "Child"}) */ abstract class Main { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue */ protected $id; } /** * @ORM\Entity */ class Child extends Main { private $someProperty; // Not a column } $child = new Child(); $em->persist($child); $em->flush(); ``` #### Expected behavior Successful insert with no exception.
admin closed this issue 2026-01-22 15:30:26 +01:00
Author
Owner

@SenseException commented on GitHub (Sep 23, 2019):

Thank you for reporting this issue. Can you please create a PR with a failing test? The described behavior differs from the 2.x versions and afaik isn't supposed to break.

@SenseException commented on GitHub (Sep 23, 2019): Thank you for reporting this issue. Can you please create a PR with a failing test? The described behavior differs from the 2.x versions and afaik isn't supposed to break.
Author
Owner

@andrews05 commented on GitHub (Sep 24, 2019):

@SenseException I've submitted a PR with a test case and possible fix.

@andrews05 commented on GitHub (Sep 24, 2019): @SenseException I've submitted a PR with a test case and possible fix.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6302