1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Right owning side column selection

This commit is contained in:
Asmir Mustafic 2014-02-06 14:26:06 +01:00
parent 2eb428df79
commit 1d40c85c3c

View File

@ -349,9 +349,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
$associationSourceClass = $this->em->getClassMetadata($mapping['targetEntity']);
$mapping = $associationSourceClass->associationMappings[$mapping['mappedBy']];
$joinColumns = $mapping['joinTable']['joinColumns'];
$relationMode = 'relationToTargetKeyColumns';
} else {
$joinColumns = $mapping['joinTable']['inverseJoinColumns'];
$associationSourceClass = $this->em->getClassMetadata($mapping['sourceEntity']);
$relationMode = 'relationToSourceKeyColumns';
}
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $associationSourceClass, $this->platform). ' t';
@ -375,13 +377,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
}
foreach ($mapping['joinTableColumns'] as $joinTableColumn) {
if (isset($mapping['relationToTargetKeyColumns'][$joinTableColumn])) {
if (isset($mapping[$relationMode][$joinTableColumn])) {
$whereClauses[] = 't.' . $joinTableColumn . ' = ?';
$params[] = $targetEntity->containsForeignIdentifier
? $id[$targetEntity->getFieldForColumn($mapping['relationToTargetKeyColumns'][$joinTableColumn])]
: $id[$targetEntity->fieldNames[$mapping['relationToTargetKeyColumns'][$joinTableColumn]]];
? $id[$targetEntity->getFieldForColumn($mapping[$relationMode][$joinTableColumn])]
: $id[$targetEntity->fieldNames[$mapping[$relationMode][$joinTableColumn]]];
} elseif (!$joinNeeded) {
$whereClauses[] = 't.' . $joinTableColumn . ' = ?';
$params[] = $key;