From 9200e17bc1676fc85cee8d2d40691e3fe76c60fd Mon Sep 17 00:00:00 2001 From: romanb Date: Thu, 15 Oct 2009 17:07:37 +0000 Subject: [PATCH] [2.0][DDC-51] Fixed. --- lib/Doctrine/ORM/Mapping/OneToManyMapping.php | 16 ++++++++-------- lib/Doctrine/ORM/Mapping/OneToOneMapping.php | 4 ++-- .../OneToManyBidirectionalAssociationTest.php | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/OneToManyMapping.php b/lib/Doctrine/ORM/Mapping/OneToManyMapping.php index c9c24eae5..bb157aa9c 100644 --- a/lib/Doctrine/ORM/Mapping/OneToManyMapping.php +++ b/lib/Doctrine/ORM/Mapping/OneToManyMapping.php @@ -106,13 +106,13 @@ class OneToManyMapping extends AssociationMapping } /** + * Loads a one-to-many collection. * - * - * @param $sourceEntity - * @param $targetCollection - * @param $em - * @param $joinColumnValues - * @return unknown_type + * @param $sourceEntity The entity that owns the collection. + * @param $targetCollection The collection to load/fill. + * @param $em The EntityManager to use. + * @param $joinColumnValues + * @return void */ public function load($sourceEntity, $targetCollection, $em, array $joinColumnValues = array()) { @@ -121,9 +121,9 @@ class OneToManyMapping extends AssociationMapping $sourceClass = $em->getClassMetadata($this->sourceEntityName); $owningAssoc = $em->getClassMetadata($this->targetEntityName)->associationMappings[$this->mappedByFieldName]; // TRICKY: since the association is specular source and target are flipped - foreach ($owningAssoc->getTargetToSourceKeyColumns() as $sourceKeyColumn => $targetKeyColumn) { + foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) { // getting id - if (isset($sourceClass->reflFields[$sourceKeyColumn])) { + if (isset($sourceClass->fieldNames[$sourceKeyColumn])) { $conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); } else { $conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn]; diff --git a/lib/Doctrine/ORM/Mapping/OneToOneMapping.php b/lib/Doctrine/ORM/Mapping/OneToOneMapping.php index 93780ced1..f11196ea4 100644 --- a/lib/Doctrine/ORM/Mapping/OneToOneMapping.php +++ b/lib/Doctrine/ORM/Mapping/OneToOneMapping.php @@ -201,7 +201,7 @@ class OneToOneMapping extends AssociationMapping if ($this->isOwningSide) { foreach ($this->sourceToTargetKeyColumns as $sourceKeyColumn => $targetKeyColumn) { // getting customer_id - if (isset($sourceClass->reflFields[$sourceKeyColumn])) { + if (isset($sourceClass->fieldNames[$sourceKeyColumn])) { $conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); } else { $conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn]; @@ -220,7 +220,7 @@ class OneToOneMapping extends AssociationMapping // TRICKY: since the association is specular source and target are flipped foreach ($owningAssoc->targetToSourceKeyColumns as $sourceKeyColumn => $targetKeyColumn) { // getting id - if (isset($sourceClass->reflFields[$sourceKeyColumn])) { + if (isset($sourceClass->fieldNames[$sourceKeyColumn])) { $conditions[$targetKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); } else { $conditions[$targetKeyColumn] = $joinColumnValues[$sourceKeyColumn]; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index df3853139..b6d2dd1d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -87,7 +87,6 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona public function testLazyLoadsObjectsOnTheOwningSide() { $this->_createFixture(); - $this->_em->getConfiguration()->setAllowPartialObjects(false); $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); $metadata->getAssociationMapping('features')->fetchMode = AssociationMapping::FETCH_LAZY;