DDC-352: JOINED inheritance doesn't remove child object #434

Open
opened 2026-01-22 12:38:07 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 19, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user cloun:

I have a two class with joined inheritance:

/****
 * @Entity(repositoryClass="Repository_Picture")
 * @Table(name="picture_ordered")
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="type", type="string")
 * @DiscriminatorMap({"url" = "Picture", "file" = "PictureFile"})
 */
class Picture extends Database_Entity {...}

/****
 * @Entity
 * @Table(name="picture_file")
 */
class PictureFile extends Picture {...}

I created PictureFile instance, added it to the Repository_Picture, flushed em. All worked fine. I saw in database one rows in the picture_ordered table and one in the picture_file table.
After that I tried to remove picture from Repository_Picture, and took the error: Integrity constraint violation
#0 E:...\library\Doctrine\DBAL\Connection.php(627): PDOStatement->execute(Array)
#1 E:...\library\Doctrine\DBAL\Connection.php(388): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM pic...', Array)
#2 E:...\library\Doctrine\ORM\Persisters\JoinedSubclassPersister.php(283): Doctrine\DBAL\Connection->delete('picture_ordered', Array)
#3 E:...\library\Doctrine\ORM\UnitOfWork.php(785): Doctrine\ORM\Persisters\JoinedSubclassPersister->delete(Object(PictureFile))
#4 E:...\library\Doctrine\ORM\UnitOfWork.php(312): Doctrine\ORM\UnitOfWork->_executeDeletions(Object(Doctrine\ORM\Mapping\ClassMetadata))
#5 E:...\library\Doctrine\ORM\EntityManager.php(280): Doctrine\ORM\UnitOfWork->commit()
#6 E:...\application\models\Database.php(93): Doctrine\ORM\EntityManager->flush()
#7 E:...\tests\maksidom\PictureTest.php(28): Database::flush()

I think that problem is that Doctrine doesn't remove child (PictrueFile) object before removing parent (Pictrue) object.

Originally created by @doctrinebot on GitHub (Feb 19, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user cloun: I have a two class with joined inheritance: ``` /**** * @Entity(repositoryClass="Repository_Picture") * @Table(name="picture_ordered") * @InheritanceType("JOINED") * @DiscriminatorColumn(name="type", type="string") * @DiscriminatorMap({"url" = "Picture", "file" = "PictureFile"}) */ class Picture extends Database_Entity {...} /**** * @Entity * @Table(name="picture_file") */ class PictureFile extends Picture {...} ``` I created PictureFile instance, added it to the Repository_Picture, flushed em. All worked fine. I saw in database one rows in the picture_ordered table and one in the picture_file table. After that I tried to remove picture from Repository_Picture, and took the error: Integrity constraint violation #0 E:...\library\Doctrine\DBAL\Connection.php(627): PDOStatement->execute(Array) #1 E:...\library\Doctrine\DBAL\Connection.php(388): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM pic...', Array) #2 E:...\library\Doctrine\ORM\Persisters\JoinedSubclassPersister.php(283): Doctrine\DBAL\Connection->delete('picture_ordered', Array) #3 E:...\library\Doctrine\ORM\UnitOfWork.php(785): Doctrine\ORM\Persisters\JoinedSubclassPersister->delete(Object(PictureFile)) #4 E:...\library\Doctrine\ORM\UnitOfWork.php(312): Doctrine\ORM\UnitOfWork->_executeDeletions(Object(Doctrine\ORM\Mapping\ClassMetadata)) #5 E:...\library\Doctrine\ORM\EntityManager.php(280): Doctrine\ORM\UnitOfWork->commit() #6 E:...\application\models\Database.php(93): Doctrine\ORM\EntityManager->flush() #7 E:...\tests\maksidom\PictureTest.php(28): Database::flush() I think that problem is that Doctrine doesn't remove child (PictrueFile) object before removing parent (Pictrue) object.
admin added the Bug label 2026-01-22 12:38:07 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#434