mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-149: No owner found for field when selecting from a table with @InheritanceType SINGLE_TABLE #186
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 @doctrinebot on GitHub (Nov 16, 2009).
Jira issue originally created by user rickdt:
In class AbstractHydrator::_gatherScalarRowData, I get an exception when the result contain metaMappings.
The problem is that $fieldName is empty when obtained this way :
$fieldName = $this->_rsm->fieldMappings[$key];
I think you should also check into :
$this->_rsm->metaMappings[$key];
May a better way would be to add a public function to ResultSetMapping like getMappedFieldName() which would look into both properties.
Here is the exception :
#0 [internal function]: Doctrine\Common\DoctrineException::**callStatic('noOwnerFoundFor...', Array)
#1 /home/eric/Zend/workspaces/DefaultWorkspace7/fna/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php(316): Doctrine\Common\DoctrineException::noOwnerFoundForField(Object(Doctrine\ORM\Mapping\ClassMetadata), NULL)
#2 /home/eric/Zend/workspaces/DefaultWorkspace7/fna/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php(267): Doctrine\ORM\Internal\Hydration\AbstractHydrator->_lookupDeclaringClass(Object(Doctrine\ORM\Mapping\ClassMetadata), NULL)
#3 /home/eric/Zend/workspaces/DefaultWorkspace7/fna/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php(42): Doctrine\ORM\Internal\Hydration\AbstractHydrator->_gatherScalarRowData(Array, Array)
#4 /home/eric/Zend/workspaces/DefaultWorkspace7/fna/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php(103): Doctrine\ORM\Internal\Hydration\ScalarHydrator->_hydrateAll()
#5 /home/eric/Zend/workspaces/DefaultWorkspace7/fna/lib/Doctrine/ORM/AbstractQuery.php(497): Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(Object(Doctrine\DBAL\Driver\PDOStatement), Object(Doctrine\ORM\Query\ResultSetMapping), Array)
#6 /home/eric/Zend/workspaces/DefaultWorkspace7/fna/lib/Doctrine/ORM/AbstractQuery.php(361): Doctrine\ORM\AbstractQuery->execute(Array, 3)
#7 /home/eric/Zend/workspaces/DefaultWorkspace7/fna/application/Kronos/FNA/View/FNA/FNAList.php(99): Doctrine\ORM\AbstractQuery->getScalarResult()
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by romanb:
Can you give us some code to reproduce?
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
I did not test with this, but here is a simplified version of my entity classes et my query.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
This comment have been moved to DDC-150
I have another major problem with the same class. I can open an other case if you want.
The discriminator value column is lost after querying on an object.
Before this, $rev_type field equal "HEAD". After, it is empty string.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by romanb:
Why do you map the discriminator column to a property? Just like foreign keys its not intended to be visible in your classes, its a detail of the relational database.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
I did this trying to workaround the bug.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
If I remove the discriminator column from the entity, I still get the "No owner found for field" error and the proposed fix (look into meta mapping) does not work.
Maybe the field should just be ignored.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
Are you OK to investigate on this or you need more input from me ?
I may also simulate this behavior at application level if you tell me this feature is too far away from being ready for use.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by romanb:
There are still some things that are unclear to me.
You're talking of AbstractHydrator::_gatherScalarRowData but the query you've shown is not scalar. What do you use to get the result? ->getScalarResult()?
The exception noOwnerFoundForField... should contain the name of the field and possible the class that causes the problem. Can you show the full exception message?
The line numbers in the stack trace dont seem to match with mine. What version/revision are you using?
A failing test case would be best. That means either a phpunit test or a small functional version as an attachment that reproduces the issue.
Thanks for your help.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by romanb:
OK, my first question is answered when looking at the stack trace. So you use getScalarResult.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by romanb:
I will try to make a test for Single Table Inheritance + getScalarResult in our test suite. Maybe this shows the issue already.
I will report back as soon as I have more questions.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
The comment at 16/Nov/09 02:40 PM is not related to this issue. I should have created an other issue.
That's because fieldName is empty. (It does not exists in $this->_rsm->fieldMappings)
I removed the last lines of the stack trace because they where related to my project. (I use revision 6727)
For the test case. This represent quiet some work and if it's not absolutely necessary, I prefer not do it.
Thank You!
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
For the line numbers in the stack trace, I just understood your question.
Line number are different because I added some debugging output.
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
Got it !
That was so simpe, I dont't know why we did not see it.
*gatherScalarRowData is missing a case that is properly handled by *gatherRowData
@doctrinebot commented on GitHub (Nov 16, 2009):
Comment created by rickdt:
This fix the issue
@doctrinebot commented on GitHub (Nov 16, 2009):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/8d6b5470301d470a8d11