When querying a simple entity which uses single table- or class table inheritance using simple object hydration (AbstractQuery::HYDRATE_SIMPLEOBJECT), the mapped discriminator column is not retrieved correctly.
The SQL statement used is equal to:
As you can see, the type column is given an alias of type1. This is saved in the ResultSetMapping of the request but not taken into account when actually retrieving the discriminator column back from the SQL result.
The problem is inside SimpleObjectHydrator#hydrateRowData().
When the discriminator column name is fetched via
the result is simply type which is wrong because the alias is type2. This can be fixed by adding
right after the column retrieval, because then the alias of the meta field type is correctly taken into account.
I'll create a PR with a unit test for this fix right after this ticket's creation.
I hope I'm doing everything right, this is my first contribution.