orm: OneToOne relationship with owning side having key of inverse side broken

gist created by @Ocramius shows a reproducible case for this issue: https://gist.github.com/Ocramius/7adc2079884991122ca95a74d2eb4927

When hydrating an entity constructed as per the gist above using findOneBy, the ORM raises a notice starting Notice: Undefined index: targetToSourceKeyColumns. I believe the issue is not reproducible when using find.

Unsure as to the root cause of the issue currently. Apologies for the vague description here, but @Ocramius will hopefully be able to provide more detail about this issue.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 17 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I executed that gist (just changing the names to GH6124* to relate to this issue) and I had a different error on master - so probably we already fixed that notice.

Basically the ORM complains that it wasn’t able to call the method BasicEntityPersister#getCacheRegion() because the mapping side is not cacheable. However if I enable L2C on the OwingSide class, and also on the association, the test passes with find() and findOneBy(): https://gist.github.com/lcobucci/665d1f03d72af1c03c5e76af6d64b1d1

PHPUnit 5.7-gb0c4a96 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 415 ms, Memory: 10.00MB

There was 1 error:

1) Doctrine\Tests\ORM\Functional\Ticket\GH6124Test::testIssue
Exception: [Error] Call to undefined method Doctrine\ORM\Persisters\Entity\BasicEntityPersister::getCacheRegion()

With queries:
9. SQL: 'SELECT t0.id AS id_1, t0.name AS name_2, t3.gh6124_inverse_side_id AS gh6124_inverse_side_id_4 FROM GH6124InverseSide t0 LEFT JOIN GH6124OwningSide t3 ON t3.gh6124_inverse_side_id = t0.id WHERE t0.name = ? LIMIT 1' Params: 'name58233cc3e27ba1.69337219'
8. SQL: '"COMMIT"' Params: 
7. SQL: 'INSERT INTO GH6124OwningSide (gh6124_inverse_side_id) VALUES (?)' Params: 1
6. SQL: '"START TRANSACTION"' Params: 
5. SQL: '"COMMIT"' Params: 
4. SQL: 'INSERT INTO GH6124InverseSide (name) VALUES (?)' Params: 'name58233cc3e27ba1.69337219'
3. SQL: '"START TRANSACTION"' Params: 
2. SQL: 'CREATE TABLE GH6124OwningSide (gh6124_inverse_side_id INTEGER NOT NULL, PRIMARY KEY(gh6124_inverse_side_id), CONSTRAINT FK_4833BEE3DCA6C60D FOREIGN KEY (gh6124_inverse_side_id) REFERENCES GH6124InverseSide (id) NOT DEFERRABLE INITIALLY IMMEDIATE)' Params: 
1. SQL: 'CREATE TABLE GH6124InverseSide (id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))' Params: 

Trace:
/vhosts/doctrine2/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:278
/vhosts/doctrine2/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:389
/vhosts/doctrine2/lib/Doctrine/ORM/EntityRepository.php:196
/vhosts/doctrine2/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6124Test.php:54
/vhosts/doctrine2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1103
/vhosts/doctrine2/vendor/phpunit/phpunit/src/Framework/TestCase.php:954
/vhosts/doctrine2/vendor/phpunit/phpunit/src/Framework/TestResult.php:701
/vhosts/doctrine2/vendor/phpunit/phpunit/src/Framework/TestCase.php:909
/vhosts/doctrine2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:753
/vhosts/doctrine2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:465
/vhosts/doctrine2/vendor/phpunit/phpunit/src/TextUI/Command.php:185
/vhosts/doctrine2/vendor/phpunit/phpunit/src/TextUI/Command.php:115
/vhosts/doctrine2/vendor/phpunit/phpunit/phpunit:47


/vhosts/doctrine2/tests/Doctrine/Tests/OrmFunctionalTestCase.php:785

Caused by
Error: Call to undefined method Doctrine\ORM\Persisters\Entity\BasicEntityPersister::getCacheRegion()

/vhosts/doctrine2/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:321
/vhosts/doctrine2/lib/Doctrine/ORM/Cache/DefaultQueryCache.php:278
/vhosts/doctrine2/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:389
/vhosts/doctrine2/lib/Doctrine/ORM/EntityRepository.php:196
/vhosts/doctrine2/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6124Test.php:54

ERRORS!
Tests: 1, Assertions: 3, Errors: 1.