{"record":{"id":"a870628d5e7dcf8c","repo":"doctrine/orm","slug":"no-persister-found-for-entity","errorCode":null,"errorMessage":"No persister found for entity.","messagePattern":"No persister found for entity\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/UnitOfWork.php","lineNumber":2931,"sourceCode":"\n    /**\n     * Gets the EntityPersister for an Entity.\n     *\n     * @param class-string $entityName The name of the Entity.\n     */\n    public function getEntityPersister(string $entityName): EntityPersister\n    {\n        if (isset($this->persisters[$entityName])) {\n            return $this->persisters[$entityName];\n        }\n\n        $class = $this->em->getClassMetadata($entityName);\n\n        $persister = match (true) {\n            $class->isInheritanceTypeNone() => new BasicEntityPersister($this->em, $class),\n            $class->isInheritanceTypeSingleTable() => new SingleTablePersister($this->em, $class),\n            $class->isInheritanceTypeJoined() => new JoinedSubclassPersister($this->em, $class),\n            default => throw new RuntimeException('No persister found for entity.'),\n        };\n\n        if ($this->hasCache && $class->cache !== null) {\n            $persister = $this->em->getConfiguration()\n                ->getSecondLevelCacheConfiguration()\n                ->getCacheFactory()\n                ->buildCachedEntityPersister($this->em, $persister, $class);\n        }\n\n        $this->persisters[$entityName] = $persister;\n\n        return $this->persisters[$entityName];\n    }\n\n    /** Gets a collection persister for a collection-valued association. */\n    public function getCollectionPersister(AssociationMapping $association): CollectionPersister\n    {\n        $role = isset($association->cache)","sourceCodeStart":2913,"sourceCodeEnd":2949,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/UnitOfWork.php#L2913-L2949","documentation":"UnitOfWork::getEntityPersister() selects a persister by the class's inheritance type: no inheritance -> BasicEntityPersister, SINGLE_TABLE -> SingleTablePersister, JOINED -> JoinedSubclassPersister. Any other inheritance type has no persister implementation - in practice TABLE_PER_CLASS, which Doctrine ORM persisters have never implemented - so the default arm of the match throws for every load/save operation on such an entity.","triggerScenarios":"Any EntityManager operation (find, persist, flush, lazy-load, collection access) on an entity whose ClassMetadata inheritanceType is neither NONE, SINGLE_TABLE nor JOINED - typically TABLE_PER_CLASS (4) coming from hand-crafted metadata or stale cached metadata after an inheritance-mapping change that was deployed without invalidating the metadata cache.","commonSituations":"Metadata caches (APCu, file, Redis) not cleared after editing #[InheritanceType] attributes; experimenting with TABLE_PER_CLASS inheritance; custom metadata factories producing an unsupported type; deploying mapping changes across a cluster where one node serves old cached metadata.","solutions":["Clear and rebuild the metadata cache after changing inheritance mapping (bin/console cache:clear, doctrine orm:clear-cache:metadata).","Switch the class to a supported strategy: SINGLE_TABLE or JOINED, or drop inheritance for a standalone entity.","If the metadata is hand-built (custom metadata factory/generator), fix it to emit one of the three supported inheritance types."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// At boot/build time, assert every entity uses a persister-supported inheritance type\nforeach ($metadataFactory->getAllMetadata() as $class) {\n    $supported = $class->isInheritanceTypeNone()\n        || $class->isInheritanceTypeSingleTable()\n        || $class->isInheritanceTypeJoined();\n    if (! $supported) {\n        throw new InvalidArgumentException($class->getName() . ' uses an unsupported inheritance type');\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clear metadata caches whenever inheritance mapping changes (include it in the deploy checklist)","Use only SINGLE_TABLE or JOINED inheritance in ORM mappings","Validate all metadata in a CI step so a bad mapping fails the build, not production traffic"],"tags":["doctrine-orm","unit-of-work","persister","inheritance-mapping","metadata-cache","table-per-class"],"backgroundTag":"orm-unsupported-inheritance-type","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}