diff --git a/lib/Doctrine/ORM/Mapping/ManyToManyMapping.php b/lib/Doctrine/ORM/Mapping/ManyToManyMapping.php index 7c75a7304..a07163424 100644 --- a/lib/Doctrine/ORM/Mapping/ManyToManyMapping.php +++ b/lib/Doctrine/ORM/Mapping/ManyToManyMapping.php @@ -163,7 +163,7 @@ class ManyToManyMapping extends AssociationMapping if ($this->isOwningSide) { foreach ($this->sourceToRelationKeyColumns as $sourceKeyColumn => $relationKeyColumn) { // getting id - if (isset($sourceClass->reflFields[$sourceKeyColumn])) { + if (isset($sourceClass->fieldNames[$sourceKeyColumn])) { $joinTableConditions[$relationKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); } else { $joinTableConditions[$relationKeyColumn] = $joinColumnValues[$sourceKeyColumn]; @@ -174,7 +174,7 @@ class ManyToManyMapping extends AssociationMapping // TRICKY: since the association is inverted source and target are flipped foreach ($owningAssoc->targetToRelationKeyColumns as $sourceKeyColumn => $relationKeyColumn) { // getting id - if (isset($sourceClass->reflFields[$sourceKeyColumn])) { + if (isset($sourceClass->fieldNames[$sourceKeyColumn])) { $joinTableConditions[$relationKeyColumn] = $sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); } else { $joinTableConditions[$relationKeyColumn] = $joinColumnValues[$sourceKeyColumn]; diff --git a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php index db67ef80e..50e80e63a 100644 --- a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php @@ -576,9 +576,11 @@ class StandardEntityPersister protected function _getSelectManyToManyEntityCollectionSql($manyToMany, array &$criteria) { $columnList = ''; + $tableName = $this->_class->getQuotedTableName($this->_platform); + foreach ($this->_class->fieldNames as $field) { if ($columnList != '') $columnList .= ', '; - $columnList .= $this->_class->getQuotedColumnName($field, $this->_platform); + $columnList .= $tableName . '.' . $this->_class->getQuotedColumnName($field, $this->_platform); } foreach ($this->_class->associationMappings as $assoc) { diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php index ea1d9196e..d79c1a298 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -15,8 +15,7 @@ use Doctrine\Common\Collections\ArrayCollection; class ECommerceCategory { /** - * @Column(type="integer") - * @Id + * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; diff --git a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php index f4f1432a0..e4141822a 100644 --- a/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php +++ b/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -40,8 +40,8 @@ class ECommerceProduct /** * @ManyToMany(targetEntity="ECommerceCategory", cascade={"persist"}) * @JoinTable(name="ecommerce_products_categories", - joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, - inverseJoinColumns={@JoinColumn(name="category_id", referencedColumnName="id")}) + * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, + * inverseJoinColumns={@JoinColumn(name="category_id", referencedColumnName="id")}) */ private $categories;