mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
find() doesn't Hydrate object with Single Table Inheritance (SINGLE_TABLE) child object #6414
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yosvield on GitHub (Feb 27, 2020).
Bug Report
Summary
When the object is searched, the child object fields are in null
How to reproduce
i have relationship
children class
When the object is searched, the children class fields are in null
Expected behavior
find child object
@yosvield commented on GitHub (Feb 28, 2020):
I already solved the problem, in the mapping the data type of the discriminatorColumn had it as bigint and in the SimpleObjectHydrator.php class when compared with the discriminatorValue the data type is different.
if (isset($cacheKeyInfo['discriminatorValues']) && ! in_array($discrColumnValue, $cacheKeyInfo['discriminatorValues'], true)) {Fix
@beberlei commented on GitHub (Feb 29, 2020):
@yosvield the problem is really that bigints must be treated as strings, so you can keep the mapping, but your code must be:
That can be a bit confusing at times
@Russellmd commented on GitHub (Mar 2, 2020):
@beberlei is it mandatory to have @DiscriminatorColumn as string type? I found similar issue today, after upgrade (Symfony + Doctrine).
In my case I use Class Table Inheritance ( InheritanceType("JOINED") ), DiscriminatorColumn of type integer. The issue is that my object's fields from joined table are not initialized. Only if I change type for DiscriminatorColumn to string it works as expected.
@beberlei commented on GitHub (Mar 2, 2020):
@Russellmd i don't know to be honest