Skip to content

Commit 5e8d809

Browse files
committed
check if foreign key is composite
1 parent 158605b commit 5e8d809

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/UnitOfWork.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
use function array_sum;
6262
use function array_values;
6363
use function assert;
64+
use function count;
6465
use function current;
6566
use function func_get_arg;
6667
use function func_num_args;
@@ -3162,8 +3163,10 @@ public function createEntity($className, array $data, &$hints = [])
31623163
$reflField->setValue($entity, $pColl);
31633164

31643165
if ($hints['fetchMode'][$class->name][$field] === ClassMetadata::FETCH_EAGER) {
3165-
$isIteration = isset($hints[Query::HINT_INTERNAL_ITERATION]) && $hints[Query::HINT_INTERNAL_ITERATION];
3166-
if ($assoc['type'] === ClassMetadata::ONE_TO_MANY && ! $isIteration && ! $targetClass->isIdentifierComposite && ! isset($assoc['indexBy'])) {
3166+
$isIteration = isset($hints[Query::HINT_INTERNAL_ITERATION]) && $hints[Query::HINT_INTERNAL_ITERATION];
3167+
$isForeignKeyComposite = count($targetClass->getAssociationMapping($assoc['mappedBy'])['joinColumns']) > 1;
3168+
3169+
if ($assoc['type'] === ClassMetadata::ONE_TO_MANY && ! $isIteration && ! $isForeignKeyComposite && ! isset($assoc['indexBy'])) {
31673170
$this->scheduleCollectionForBatchLoading($pColl, $class);
31683171
} else {
31693172
$this->loadCollection($pColl);

0 commit comments

Comments
 (0)