Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/d7c77b87fa2066dff479 to your computer and use it in GitHub Desktop.
Save doctrinebot/d7c77b87fa2066dff479 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-193 - https://github.com/doctrine/doctrine2/issues/2599
Index: tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php
===================================================================
--- tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php (revision 7504)
+++ tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php (working copy)
@@ -17,17 +17,17 @@
/**
* @Column(type="integer")
* @Id
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
private $id;
/**
- * @Column(type="string", length=50, nullable=true)
+ * @Column(length=50, nullable=true)
*/
private $payment;
/**
- * @OneToOne(targetEntity="ECommerceCustomer")
+ * @OneToOne(targetEntity="ECommerceCustomer", inversedBy="cart")
* @JoinColumn(name="customer_id", referencedColumnName="id")
*/
private $customer;
Index: tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php
===================================================================
--- tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php (revision 7504)
+++ tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php (working copy)
@@ -14,17 +14,17 @@
/**
* @Column(type="integer")
* @Id
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
private $id;
/**
- * @Column(type="string", length=50)
+ * @Column(length=50)
*/
private $description;
/**
- * @ManyToOne(targetEntity="ECommerceProduct")
+ * @ManyToOne(targetEntity="ECommerceProduct", inversedBy="features")
* @JoinColumn(name="product_id", referencedColumnName="id")
*/
private $product;
Index: tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php
===================================================================
--- tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php (revision 7504)
+++ tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php (working copy)
@@ -36,7 +36,7 @@
private $children;
/**
- * @ManyToOne(targetEntity="ECommerceCategory")
+ * @ManyToOne(targetEntity="ECommerceCategory", inversedBy="children")
* @JoinColumn(name="parent_id", referencedColumnName="id")
*/
private $parent;
Index: tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php
===================================================================
--- tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php (revision 7504)
+++ tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php (working copy)
@@ -10,14 +10,14 @@
*
* @author Giorgio Sironi
* @Entity
- * @Table(name="ecommerce_products",indexes={@index(name="name_idx", columns={"name"})})
+ * @Table(name="ecommerce_products",indexes={@Index(name="name_idx", columns={"name"})})
*/
class ECommerceProduct
{
/**
* @Column(type="integer")
* @Id
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
private $id;
@@ -38,7 +38,7 @@
private $features;
/**
- * @ManyToMany(targetEntity="ECommerceCategory", cascade={"persist"})
+ * @ManyToMany(targetEntity="ECommerceCategory", cascade={"persist"}, inversedBy="products")
* @JoinTable(name="ecommerce_products_categories",
* joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="category_id", referencedColumnName="id")})
@@ -50,8 +50,8 @@
* simplicity.
* @ManyToMany(targetEntity="ECommerceProduct", cascade={"persist"})
* @JoinTable(name="ecommerce_products_related",
- joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
- inverseJoinColumns={@JoinColumn(name="related_id", referencedColumnName="id")})
+ * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
+ * inverseJoinColumns={@JoinColumn(name="related_id", referencedColumnName="id")})
*/
private $related;
Index: tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php
===================================================================
--- tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php (revision 7504)
+++ tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php (working copy)
@@ -14,7 +14,7 @@
{
/**
* @Id @Column(type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
private $id;
Index: tests/Doctrine/Tests/Models/CMS/CmsGroup.php
===================================================================
--- tests/Doctrine/Tests/Models/CMS/CmsGroup.php (revision 7504)
+++ tests/Doctrine/Tests/Models/CMS/CmsGroup.php (working copy)
@@ -18,11 +18,11 @@
/**
* @Id
* @Column(type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
public $id;
/**
- * @Column(type="string", length=50)
+ * @Column(length=50)
*/
public $name;
/**
Index: tests/Doctrine/Tests/Models/CMS/CmsUser.php
===================================================================
--- tests/Doctrine/Tests/Models/CMS/CmsUser.php (revision 7504)
+++ tests/Doctrine/Tests/Models/CMS/CmsUser.php (working copy)
@@ -40,7 +40,7 @@
*/
public $address;
/**
- * @ManyToMany(targetEntity="CmsGroup", cascade={"persist"})
+ * @ManyToMany(targetEntity="CmsGroup", inversedBy="users", cascade={"persist"})
* @JoinTable(name="cms_users_groups",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}
Index: tests/Doctrine/Tests/Models/CMS/CmsEmployee.php
===================================================================
--- tests/Doctrine/Tests/Models/CMS/CmsEmployee.php (revision 7504)
+++ tests/Doctrine/Tests/Models/CMS/CmsEmployee.php (working copy)
@@ -14,12 +14,12 @@
/**
* @Id
* @Column(type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
private $id;
/**
- * @Column(type="string")
+ * @Column
*/
private $name;
Index: tests/Doctrine/Tests/Models/CMS/CmsComment.php
===================================================================
--- tests/Doctrine/Tests/Models/CMS/CmsComment.php (revision 7504)
+++ tests/Doctrine/Tests/Models/CMS/CmsComment.php (working copy)
@@ -23,7 +23,7 @@
*/
public $text;
/**
- * @ManyToOne(targetEntity="CmsArticle")
+ * @ManyToOne(targetEntity="CmsArticle", inversedBy="comments")
* @JoinColumn(name="article_id", referencedColumnName="id")
*/
public $article;
Index: tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php
===================================================================
--- tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php (revision 7504)
+++ tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php (working copy)
@@ -9,11 +9,11 @@
class CmsPhonenumber
{
/**
- * @Id @Column(type="string", length=50)
+ * @Id @Column(length=50)
*/
public $phonenumber;
/**
- * @ManyToOne(targetEntity="CmsUser")
+ * @ManyToOne(targetEntity="CmsUser", inversedBy="phonenumbers")
* @JoinColumn(name="user_id", referencedColumnName="id")
*/
public $user;
Index: tests/Doctrine/Tests/Models/CMS/CmsArticle.php
===================================================================
--- tests/Doctrine/Tests/Models/CMS/CmsArticle.php (revision 7504)
+++ tests/Doctrine/Tests/Models/CMS/CmsArticle.php (working copy)
@@ -23,7 +23,7 @@
*/
public $text;
/**
- * @ManyToOne(targetEntity="CmsUser")
+ * @ManyToOne(targetEntity="CmsUser", inversedBy="articles")
* @JoinColumn(name="user_id", referencedColumnName="id")
*/
public $user;
Index: tests/Doctrine/Tests/Models/CMS/CmsAddress.php
===================================================================
--- tests/Doctrine/Tests/Models/CMS/CmsAddress.php (revision 7504)
+++ tests/Doctrine/Tests/Models/CMS/CmsAddress.php (working copy)
@@ -13,23 +13,22 @@
{
/**
* @Column(type="integer")
- * @Id
- * @GeneratedValue(strategy="AUTO")
+ * @Id @GeneratedValue
*/
public $id;
/**
- * @Column(type="string", length=50)
+ * @Column(length=50)
*/
public $country;
/**
- * @Column(type="string", length=50)
+ * @Column(length=50)
*/
public $zip;
/**
- * @Column(type="string", length=50)
+ * @Column(length=50)
*/
public $city;
@@ -39,8 +38,7 @@
public $street;
/**
- * @OneToOne(targetEntity="CmsUser")
-// * @JoinColumn(name="user_id", referencedColumnName="id")
+ * @OneToOne(targetEntity="CmsUser", inversedBy="address")
*/
public $user;
Index: tests/Doctrine/Tests/Models/Company/CompanyPerson.php
===================================================================
--- tests/Doctrine/Tests/Models/Company/CompanyPerson.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Company/CompanyPerson.php (working copy)
@@ -20,11 +20,11 @@
/**
* @Id
* @Column(type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
private $id;
/**
- * @Column(type="string")
+ * @Column
*/
private $name;
/**
Index: tests/Doctrine/Tests/Models/Company/CompanyRaffle.php
===================================================================
--- tests/Doctrine/Tests/Models/Company/CompanyRaffle.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Company/CompanyRaffle.php (working copy)
@@ -4,7 +4,7 @@
/** @Entity @Table(name="company_raffles") */
class CompanyRaffle extends CompanyEvent {
- /** @Column(type="string") */
+ /** @Column */
private $data;
public function setData($data) {
Index: tests/Doctrine/Tests/Models/Company/CompanyEvent.php
===================================================================
--- tests/Doctrine/Tests/Models/Company/CompanyEvent.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Company/CompanyEvent.php (working copy)
@@ -11,12 +11,12 @@
class CompanyEvent {
/**
* @Id @Column(type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
private $id;
/**
- * @ManyToOne(targetEntity="CompanyOrganization",cascade={"persist"})
+ * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"})
* @JoinColumn(name="org_id", referencedColumnName="id")
*/
private $organization;
Index: tests/Doctrine/Tests/Models/Routing/RoutingLeg.php
===================================================================
--- tests/Doctrine/Tests/Models/Routing/RoutingLeg.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Routing/RoutingLeg.php (working copy)
@@ -8,20 +8,19 @@
class RoutingLeg
{
/**
- * @Id
- * @generatedValue(strategy="AUTO")
+ * @Id @generatedValue
* @column(type="integer")
*/
public $id;
/**
- * @ManyToOne(targetEntity="Doctrine\Tests\Models\Routing\RoutingLocation")
+ * @ManyToOne(targetEntity="RoutingLocation")
* @JoinColumn(name="from_id", referencedColumnName="id")
*/
public $fromLocation;
/**
- * @ManyToOne(targetEntity="Doctrine\Tests\Models\Routing\RoutingLocation")
+ * @ManyToOne(targetEntity="RoutingLocation")
* @JoinColumn(name="to_id", referencedColumnName="id")
*/
public $toLocation;
Index: tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php
===================================================================
--- tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php (working copy)
@@ -10,12 +10,12 @@
/**
* @Id
* @Column(type="integer")
- * @generatedValue(strategy="AUTO")
+ * @GeneratedValue
*/
public $id;
/**
- * @ManyToOne(targetEntity="RoutingRoute")
+ * @ManyToOne(targetEntity="RoutingRoute", inversedBy="bookings")
* @JoinColumn(name="route_id", referencedColumnName="id")
*/
public $route;
Index: tests/Doctrine/Tests/Models/Routing/RoutingLocation.php
===================================================================
--- tests/Doctrine/Tests/Models/Routing/RoutingLocation.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Routing/RoutingLocation.php (working copy)
@@ -8,8 +8,7 @@
class RoutingLocation
{
/**
- * @Id
- * @generatedValue(strategy="AUTO")
+ * @Id @GeneratedValue
* @Column(type="integer")
*/
public $id;
Index: tests/Doctrine/Tests/Models/Routing/RoutingRoute.php
===================================================================
--- tests/Doctrine/Tests/Models/Routing/RoutingRoute.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Routing/RoutingRoute.php (working copy)
@@ -11,7 +11,7 @@
{
/**
* @Id
- * @generatedValue(strategy="AUTO")
+ * @GeneratedValue
* @column(type="integer")
*/
public $id;
Index: tests/Doctrine/Tests/Models/Forum/ForumBoard.php
===================================================================
--- tests/Doctrine/Tests/Models/Forum/ForumBoard.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Forum/ForumBoard.php (working copy)
@@ -21,7 +21,7 @@
*/
public $position;
/**
- * @ManyToOne(targetEntity="ForumCategory")
+ * @ManyToOne(targetEntity="ForumCategory", inversedBy="boards")
* @JoinColumn(name="category_id", referencedColumnName="id")
*/
public $category;
Index: tests/Doctrine/Tests/Models/Forum/ForumUser.php
===================================================================
--- tests/Doctrine/Tests/Models/Forum/ForumUser.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Forum/ForumUser.php (working copy)
@@ -10,8 +10,7 @@
{
/**
* @Column(type="integer")
- * @Id
- * @GeneratedValue(strategy="AUTO")
+ * @Id @GeneratedValue
*/
public $id;
/**
Index: tests/Doctrine/Tests/Models/Generic/DateTimeModel.php
===================================================================
--- tests/Doctrine/Tests/Models/Generic/DateTimeModel.php (revision 7504)
+++ tests/Doctrine/Tests/Models/Generic/DateTimeModel.php (working copy)
@@ -10,7 +10,7 @@
{
/**
* @Id @Column(type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
public $id;
/**
Index: tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml
===================================================================
--- tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml (revision 7504)
+++ tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml (working copy)
@@ -20,7 +20,7 @@
<field name="name" column="name" type="string" length="50" nullable="true" unique="true" />
<field name="email" column="user_email" type="string" column-definition="CHAR(32) NOT NULL" />
- <one-to-one field="address" target-entity="Address">
+ <one-to-one field="address" target-entity="Address" inversed-by="user">
<cascade><cascade-remove /></cascade>
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
</one-to-one>
Index: tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
===================================================================
--- tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php (working copy)
@@ -73,7 +73,6 @@
public function testAssocations($class)
{
$this->assertEquals(3, count($class->associationMappings));
- $this->assertEquals(1, count($class->inverseMappings));
return $class;
}
@@ -87,6 +86,7 @@
$this->assertTrue($class->associationMappings['address'] instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
$this->assertTrue(isset($class->associationMappings['address']));
$this->assertTrue($class->associationMappings['address']->isOwningSide);
+ $this->assertEquals('user', $class->associationMappings['address']->inversedBy);
// Check cascading
$this->assertTrue($class->associationMappings['address']->isCascadeRemove);
$this->assertFalse($class->associationMappings['address']->isCascadePersist);
@@ -223,13 +223,12 @@
public $email;
/**
- * @OneToOne(targetEntity="Address", cascade={"remove"})
+ * @OneToOne(targetEntity="Address", cascade={"remove"}, inversedBy="user")
* @JoinColumn(onDelete="CASCADE", onUpdate="CASCADE")
*/
public $address;
/**
- *
* @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"})
* @OrderBy({"number"="ASC"})
*/
Index: tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml
===================================================================
--- tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml (revision 7504)
+++ tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml (working copy)
@@ -19,6 +19,7 @@
oneToOne:
address:
targetEntity: Address
+ inversedBy: user
joinColumn:
name: address_id
referencedColumnName: id
Index: tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php
===================================================================
--- tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php (working copy)
@@ -39,6 +39,7 @@
0 => 'remove',
),
'mappedBy' => NULL,
+ 'inversedBy' => 'user',
'joinColumns' =>
array(
0 =>
Index: tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
===================================================================
--- tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php (working copy)
@@ -100,8 +100,8 @@
$this->assertTrue($assoc instanceof \Doctrine\ORM\Mapping\ManyToManyMapping);
$this->assertEquals(array(
'name' => 'CmsUser_CmsGroup',
- 'joinColumns' => array(array('name' => 'CmsUser_id', 'referencedColumnName' => 'id')),
- 'inverseJoinColumns' => array(array('name' => 'CmsGroup_id', 'referencedColumnName' => 'id'))
+ 'joinColumns' => array(array('name' => 'CmsUser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')),
+ 'inverseJoinColumns' => array(array('name' => 'CmsGroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE'))
), $assoc->joinTable);
}
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php (working copy)
@@ -68,7 +68,7 @@
{
/**
* @Id
- * @generatedValue(strategy="AUTO")
+ * @GeneratedValue
* @Column(name="id", type="integer")
*/
public $id;
@@ -98,8 +98,7 @@
class DDC279EntityY
{
/**
- * @Id
- * @generatedValue(strategy="AUTO")
+ * @Id @GeneratedValue
* @Column(name="id", type="integer")
*/
public $id;
@@ -122,8 +121,7 @@
class DDC279EntityZ
{
/**
- * @Id
- * @generatedValue(strategy="AUTO")
+ * @Id @GeneratedValue
* @Column(name="id", type="integer")
*/
public $id;
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php (working copy)
@@ -79,7 +79,7 @@
class DDC199ChildClass extends DDC199ParentClass
{
/**
- * @Column(type="string")
+ * @Column
*/
public $childData;
}
@@ -87,13 +87,13 @@
/** @Entity @Table(name="ddc199_relatedclass") */
class DDC199RelatedClass
{
- /** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
+ /** @Id @Column(type="integer") @GeneratedValue */
public $id;
- /** @Column(type="string") */
+ /** @Column */
public $relatedData;
/**
- * @ManyToOne(targetEntity="DDC199ParentClass")
+ * @ManyToOne(targetEntity="DDC199ParentClass", inversedBy="relatedEntities")
* @JoinColumn(name="parent_id", referencedColumnName="id")
*/
public $parent;
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php (working copy)
@@ -212,7 +212,7 @@
/**
* @var Lemma
- * @ManyToOne(targetEntity="Lemma")
+ * @ManyToOne(targetEntity="Lemma", inversedBy="relations")
* @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id")
*/
private $parent;
@@ -226,7 +226,7 @@
/**
* @var RelationType
- * @ManyToOne(targetEntity="RelationType")
+ * @ManyToOne(targetEntity="RelationType", inversedBy="relations")
* @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id")
*/
private $type;
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php (working copy)
@@ -65,7 +65,7 @@
protected $name;
/**
- * @ManyToMany(targetEntity="DDC211Group")
+ * @ManyToMany(targetEntity="DDC211Group", inversedBy="users")
* @JoinTable(name="user_groups",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php (working copy)
@@ -43,21 +43,21 @@
*/
class DDC144FlowElement {
/**
- * @Id @Column(type="integer") @GeneratedValue(strategy="AUTO")
+ * @Id @Column(type="integer") @GeneratedValue
* @var integer
*/
public $id;
- /** @Column(type="string") */
+ /** @Column */
public $property;
}
-// /** @Entity @Table(name="ddc144_expressions") */
abstract class DDC144Expression extends DDC144FlowElement {
abstract function method();
}
+
/** @Entity @Table(name="ddc144_operands") */
class DDC144Operand extends DDC144Expression {
- /** @Column(type="string") */
+ /** @Column */
public $operandProperty;
function method() {}
}
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php (working copy)
@@ -78,8 +78,7 @@
{
/**
* @Column(name="picture_id", type="integer")
- * @Id
- * @GeneratedValue(strategy="AUTO")
+ * @Id @GeneratedValue
*/
private $pictureId;
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php (working copy)
@@ -53,7 +53,7 @@
private $id;
/** @Column(type="string") */
public $data;
- /** @ManyToOne(targetEntity="DDC371Parent") @JoinColumn(name="parentId") */
+ /** @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") @JoinColumn(name="parentId") */
public $parent;
}
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php (working copy)
@@ -54,7 +54,7 @@
/**
* @Id
* @Column(name="id", type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
public $id;
}
@@ -67,7 +67,7 @@
/**
* @Id
* @Column(name="id", type="integer")
- * @GeneratedValue(strategy="AUTO")
+ * @GeneratedValue
*/
public $id;
}
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php (working copy)
@@ -68,7 +68,7 @@
class DDC237EntityX
{
/**
- * @Id @Column(type="integer") @GeneratedValue(strategy="AUTO")
+ * @Id @Column(type="integer") @GeneratedValue
*/
public $id;
/**
@@ -87,7 +87,7 @@
class DDC237EntityY
{
/**
- * @Id @Column(type="integer") @GeneratedValue(strategy="AUTO")
+ * @Id @Column(type="integer") @GeneratedValue
*/
public $id;
/**
@@ -99,7 +99,7 @@
/** @Entity @Table(name="ddc237_z") */
class DDC237EntityZ
{
- /** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
+ /** @Id @Column(type="integer") @GeneratedValue */
public $id;
/** @Column(type="string") */
public $data;
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php (working copy)
@@ -118,13 +118,13 @@
public $id;
/**
- * @OneToOne(targetEntity="DDC345User")
+ * @OneToOne(targetEntity="DDC345User", inversedBy="Memberships")
* @JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
*/
public $user;
/**
- * @OneToOne(targetEntity="DDC345Group")
+ * @OneToOne(targetEntity="DDC345Group", inversedBy="Memberships")
* @JoinColumn(name="group_id", referencedColumnName="id", nullable=false)
*/
public $group;
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php (revision 7504)
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php (working copy)
@@ -47,7 +47,7 @@
class DDC381Entity
{
/**
- * @Id @Column(type="integer") @generatedValue
+ * @Id @Column(type="integer") @GeneratedValue
*/
protected $id;
Index: lib/Doctrine/ORM/Mapping/OneToOneMapping.php
===================================================================
--- lib/Doctrine/ORM/Mapping/OneToOneMapping.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/OneToOneMapping.php (working copy)
@@ -141,18 +141,14 @@
$targetClass = $em->getClassMetadata($this->targetEntityName);
if ($this->isOwningSide) {
- $inverseField = isset($targetClass->inverseMappings[$this->sourceEntityName][$this->sourceFieldName]) ?
- $targetClass->inverseMappings[$this->sourceEntityName][$this->sourceFieldName]->sourceFieldName
- : false;
-
// Mark inverse side as fetched in the hints, otherwise the UoW would
// try to load it in a separate query (remember: to-one inverse sides can not be lazy).
$hints = array();
- if ($inverseField) {
- $hints['fetched'][$targetClass->name][$inverseField] = true;
+ if ($this->inversedBy) {
+ $hints['fetched'][$targetClass->name][$this->inversedBy] = true;
if ($targetClass->subClasses) {
foreach ($targetClass->subClasses as $targetSubclassName) {
- $hints['fetched'][$targetSubclassName][$inverseField] = true;
+ $hints['fetched'][$targetSubclassName][$this->inversedBy] = true;
}
}
}
@@ -164,8 +160,8 @@
$targetEntity = $em->getUnitOfWork()->getEntityPersister($this->targetEntityName)->load($joinColumnValues, $targetEntity, $this, $hints);
- if ($targetEntity !== null && $inverseField && ! $targetClass->isCollectionValuedAssociation($inverseField)) {
- $targetClass->reflFields[$inverseField]->setValue($targetEntity, $sourceEntity);
+ if ($targetEntity !== null && $this->inversedBy && ! $targetClass->isCollectionValuedAssociation($this->inversedBy)) {
+ $targetClass->reflFields[$this->inversedBy]->setValue($targetEntity, $sourceEntity);
}
} else {
$conditions = array();
Index: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
===================================================================
--- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (working copy)
@@ -127,9 +127,9 @@
public $namespace;
/**
- * READ-ONLY: The name of the entity class that is at the root of the entity inheritance
- * hierarchy. If the entity is not part of an inheritance hierarchy this is the same
- * as $_entityName.
+ * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance
+ * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same
+ * as {@link $entityName}.
*
* @var string
*/
@@ -313,14 +313,6 @@
public $associationMappings = array();
/**
- * READ-ONLY: List of inverse association mappings, indexed by mappedBy field name.
- *
- * @var array
- * @todo Remove! See http://www.doctrine-project.org/jira/browse/DDC-193
- */
- public $inverseMappings = array();
-
- /**
* READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite.
*
* @var boolean
@@ -532,34 +524,6 @@
}
/**
- * Gets the inverse association mapping for the given target class name and
- * owning fieldname.
- *
- * @param string $mappedByFieldName The field on the
- * @return Doctrine\ORM\Mapping\AssociationMapping The mapping or NULL if there is no such
- * inverse association mapping.
- */
- public function getInverseAssociationMapping($targetClassName, $mappedByFieldName)
- {
- return isset($this->inverseMappings[$targetClassName][$mappedByFieldName]) ?
- $this->inverseMappings[$targetClassName][$mappedByFieldName] : null;
- }
-
- /**
- * Checks whether the class has an inverse association mapping that points to the
- * specified class and ha the specified mappedBy field.
- *
- * @param string $targetClassName The name of the target class.
- * @param string $mappedByFieldName The name of the mappedBy field that points to the field on
- * the target class that owns the association.
- * @return boolean
- */
- public function hasInverseAssociationMapping($targetClassName, $mappedByFieldName)
- {
- return isset($this->inverseMappings[$targetClassName][$mappedByFieldName]);
- }
-
- /**
* Gets all association mappings of the class.
*
* @return array
@@ -1063,7 +1027,6 @@
if ($owningClassName !== null) {
$this->inheritedAssociationFields[$sourceFieldName] = $owningClassName;
}
- $this->_registerMappingIfInverse($mapping);
}
/**
@@ -1094,20 +1057,6 @@
}
/**
- * Registers the mapping as an inverse mapping, if it is a mapping on the
- * inverse side of an association mapping.
- *
- * @param AssociationMapping The mapping to register as inverse if it is a mapping
- * for the inverse side of an association.
- */
- private function _registerMappingIfInverse(AssociationMapping $assoc)
- {
- if ( ! $assoc->isOwningSide) {
- $this->inverseMappings[$assoc->targetEntityName][$assoc->mappedBy] = $assoc;
- }
- }
-
- /**
* Adds a one-to-many mapping.
*
* @param array $mapping The mapping.
@@ -1154,7 +1103,6 @@
throw MappingException::duplicateFieldMapping($this->name, $sourceFieldName);
}
$this->associationMappings[$sourceFieldName] = $assocMapping;
- $this->_registerMappingIfInverse($assocMapping);
}
/**
Index: lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php (working copy)
@@ -21,7 +21,8 @@
namespace Doctrine\ORM\Mapping\Driver;
-use Doctrine\ORM\Mapping\ClassMetadataInfo,
+use SimpleXMLElement,
+ Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\MappingException;
/**
@@ -226,6 +227,9 @@
if (isset($oneToOneElement['mapped-by'])) {
$mapping['mappedBy'] = (string)$oneToOneElement['mapped-by'];
} else {
+ if (isset($oneToOneElement['inversed-by'])) {
+ $mapping['inversedBy'] = (string)$oneToOneElement['inversed-by'];
+ }
$joinColumns = array();
if (isset($oneToOneElement->{'join-column'})) {
@@ -295,9 +299,13 @@
if (isset($manyToOneElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$manyToOneElement['fetch']);
}
-
+
+ if (isset($manyToOneElement['inversed-by'])) {
+ $mapping['inversedBy'] = (string)$manyToOneElement['inversed-by'];
+ }
+
$joinColumns = array();
-
+
if (isset($manyToOneElement->{'join-column'})) {
$joinColumns[] = $this->_getJoinColumnMapping($manyToOneElement->{'join-column'});
} else if (isset($manyToOneElement->{'join-columns'})) {
@@ -305,13 +313,12 @@
if (!isset($joinColumnElement['name'])) {
$joinColumnElement['name'] = $name;
}
-
$joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement);
}
}
-
+
$mapping['joinColumns'] = $joinColumns;
-
+
if (isset($manyToOneElement->cascade)) {
$mapping['cascade'] = $this->_getCascadeMappings($manyToOneElement->cascade);
}
@@ -339,11 +346,15 @@
if (isset($manyToManyElement['mapped-by'])) {
$mapping['mappedBy'] = (string)$manyToManyElement['mapped-by'];
} else if (isset($manyToManyElement->{'join-table'})) {
+ if (isset($manyToManyElement['inversed-by'])) {
+ $mapping['inversedBy'] = (string)$manyToManyElement['inversed-by'];
+ }
+
$joinTableElement = $manyToManyElement->{'join-table'};
$joinTable = array(
'name' => (string)$joinTableElement['name']
);
-
+
if (isset($joinTableElement['schema'])) {
$joinTable['schema'] = (string)$joinTableElement['schema'];
}
@@ -382,7 +393,7 @@
// Evaluate <lifecycle-callbacks...>
if (isset($xmlRoot->{'lifecycle-callbacks'})) {
foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) {
- $metadata->addLifecycleCallback((string)$lifecycleCallback['method'], constant('\Doctrine\ORM\Events::' . (string)$lifecycleCallback['type']));
+ $metadata->addLifecycleCallback((string)$lifecycleCallback['method'], constant('Doctrine\ORM\Events::' . (string)$lifecycleCallback['type']));
}
}
}
@@ -394,7 +405,7 @@
* @param $joinColumnElement The XML element.
* @return array The mapping array.
*/
- private function _getJoinColumnMapping(\SimpleXMLElement $joinColumnElement)
+ private function _getJoinColumnMapping(SimpleXMLElement $joinColumnElement)
{
$joinColumn = array(
'name' => (string)$joinColumnElement['name'],
Index: lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php (working copy)
@@ -230,6 +230,10 @@
if (isset($oneToOneElement['mappedBy'])) {
$mapping['mappedBy'] = $oneToOneElement['mappedBy'];
} else {
+ if (isset($oneToOneElement['inversedBy'])) {
+ $mapping['inversedBy'] = $oneToOneElement['inversedBy'];
+ }
+
$joinColumns = array();
if (isset($oneToOneElement['joinColumn'])) {
@@ -292,6 +296,10 @@
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToOneElement['fetch']);
}
+ if (isset($manyToOneElement['inversedBy'])) {
+ $mapping['inversedBy'] = $manyToOneElement['inversedBy'];
+ }
+
$joinColumns = array();
if (isset($manyToOneElement['joinColumn'])) {
@@ -331,6 +339,10 @@
if (isset($manyToManyElement['mappedBy'])) {
$mapping['mappedBy'] = $manyToManyElement['mappedBy'];
} else if (isset($manyToManyElement['joinTable'])) {
+ if (isset($manyToManyElement['inversedBy'])) {
+ $mapping['inversedBy'] = $manyToManyElement['inversedBy'];
+ }
+
$joinTableElement = $manyToManyElement['joinTable'];
$joinTable = array(
'name' => $joinTableElement['name']
@@ -375,7 +387,7 @@
if (isset($element['lifecycleCallbacks'])) {
foreach ($element['lifecycleCallbacks'] as $type => $methods) {
foreach ($methods as $method) {
- $metadata->addLifecycleCallback($method, constant('\Doctrine\ORM\Events::' . $type));
+ $metadata->addLifecycleCallback($method, constant('Doctrine\ORM\Events::' . $type));
}
}
}
Index: lib/Doctrine/ORM/Mapping/Driver/DriverChain.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/DriverChain.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/DriverChain.php (working copy)
@@ -46,7 +46,7 @@
private $_drivers = array();
/**
- * Add a nested driver
+ * Add a nested driver.
*
* @param Driver $nestedDriver
* @param string $namespace
@@ -57,7 +57,7 @@
}
/**
- * Get the array of nested drivers
+ * Get the array of nested drivers.
*
* @return array $drivers
*/
@@ -74,7 +74,7 @@
*/
public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
- foreach ($this->_drivers AS $namespace => $driver) {
+ foreach ($this->_drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
$driver->loadMetadataForClass($className, $metadata);
return;
Index: lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php (working copy)
@@ -55,7 +55,7 @@
* @var string
*/
protected $_fileExtension;
-
+
/**
* Initializes a new FileDriver that looks in the given path(s) for mapping
* documents and operates in the specified operating mode.
@@ -76,7 +76,7 @@
{
$this->_paths = array_unique(array_merge($this->_paths, $paths));
}
-
+
/**
* Retrieve the defined metadata lookup paths.
*
@@ -107,7 +107,7 @@
{
$this->_fileExtension = $fileExtension;
}
-
+
/**
* Get the element of schema meta data for the class from the mapping file.
* This will lazily load the mapping file if it is not loaded yet
@@ -132,7 +132,7 @@
public function isTransient($className)
{
$fileName = str_replace('\\', '.', $className) . $this->_fileExtension;
-
+
// Check whether file exists
foreach ((array) $this->_paths as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) {
@@ -142,7 +142,7 @@
return true;
}
-
+
/**
* Gets the names of all mapped classes known to this driver.
*
@@ -151,7 +151,7 @@
public function getAllClassNames()
{
$classes = array();
-
+
if ($this->_paths) {
foreach ((array) $this->_paths as $path) {
if ( ! is_dir($path)) {
Index: lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php (working copy)
@@ -29,7 +29,7 @@
Doctrine\Common\Util\Inflector;
/**
- * The DatabaseDriver reverse engineers the mapping metadata from a database
+ * The DatabaseDriver reverse engineers the mapping metadata from a database.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
@@ -67,7 +67,7 @@
$columns = $this->_sm->listTableColumns($tableName);
- if($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$foreignKeys = $this->_sm->listTableForeignKeys($tableName);
} else {
$foreignKeys = array();
Index: lib/Doctrine/ORM/Mapping/Driver/PhpDriver.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/PhpDriver.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/PhpDriver.php (working copy)
@@ -49,7 +49,6 @@
* {@inheritdoc}
*/
protected $_fileExtension = '.php';
-
protected $_metadata;
/**
Index: lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php (working copy)
@@ -37,7 +37,6 @@
public $length;
}
final class DiscriminatorMap extends Annotation {}
-/*final class SubClasses extends Annotation {}*/
final class Id extends Annotation {}
final class GeneratedValue extends Annotation {
public $strategy = 'AUTO';
@@ -124,7 +123,6 @@
public $initialValue = 1;
}
final class ChangeTrackingPolicy extends Annotation {}
-
final class OrderBy extends Annotation {}
/* Annotations for lifecycle callbacks */
Index: lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
===================================================================
--- lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php (working copy)
@@ -173,7 +173,7 @@
// Evaluate InheritanceType annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) {
$inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType'];
- $metadata->setInheritanceType(constant('\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
+ $metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
}
// Evaluate DiscriminatorColumn annotation
@@ -195,7 +195,7 @@
// Evaluate DoctrineChangeTrackingPolicy annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'])) {
$changeTrackingAnnot = $classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'];
- $metadata->setChangeTrackingPolicy(constant('\Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
+ $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
}
// Evaluate annotations on properties/fields
Index: lib/Doctrine/ORM/Mapping/ClassMetadata.php
===================================================================
--- lib/Doctrine/ORM/Mapping/ClassMetadata.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/ClassMetadata.php (working copy)
@@ -315,7 +315,6 @@
'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime.
'inheritanceType',
'inheritedAssociationFields',
- 'inverseMappings', //TODO: Remove! DDC-193
'isIdentifierComposite',
'isMappedSuperclass',
'isVersioned',
Index: lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
===================================================================
--- lib/Doctrine/ORM/Mapping/ManyToManyMapping.php (revision 7504)
+++ lib/Doctrine/ORM/Mapping/ManyToManyMapping.php (working copy)
@@ -70,10 +70,7 @@
public $orderBy;
/**
- * Validates and completes the mapping.
- *
- * @param array $mapping
- * @override
+ * {@inheritdoc}
*/
protected function _validateAndCompleteMapping(array $mapping)
{
@@ -89,13 +86,15 @@
'joinColumns' => array(
array(
'name' => $sourceShortName . '_id',
- 'referencedColumnName' => 'id'
+ 'referencedColumnName' => 'id',
+ 'onDelete' => 'CASCADE'
)
),
'inverseJoinColumns' => array(
array(
'name' => $targetShortName . '_id',
- 'referencedColumnName' => 'id'
+ 'referencedColumnName' => 'id',
+ 'onDelete' => 'CASCADE'
)
)
);
@@ -178,6 +177,7 @@
$persister->loadManyToManyCollection($this, $joinTableConditions, $targetCollection);
}
+ /** {@inheritdoc} */
public function isManyToMany()
{
return true;
Index: lib/Doctrine/ORM/PersistentCollection.php
===================================================================
--- lib/Doctrine/ORM/PersistentCollection.php (revision 7504)
+++ lib/Doctrine/ORM/PersistentCollection.php (working copy)
@@ -134,18 +134,7 @@
{
$this->_owner = $entity;
$this->_association = $assoc;
-
- // Check for bidirectionality
- //$this->_backRefFieldName = $assoc->inversedBy ?: $assoc->mappedBy;
- if ( ! $assoc->isOwningSide) {
- // For sure bi-directional
- $this->_backRefFieldName = $assoc->mappedBy;
- } else {
- if (isset($this->_typeClass->inverseMappings[$assoc->sourceEntityName][$assoc->sourceFieldName])) {
- // Bi-directional
- $this->_backRefFieldName = $this->_typeClass->inverseMappings[$assoc->sourceEntityName][$assoc->sourceFieldName]->sourceFieldName;
- }
- }
+ $this->_backRefFieldName = $assoc->inversedBy ?: $assoc->mappedBy;
}
/**
@@ -174,8 +163,8 @@
public function hydrateAdd($element)
{
$this->_coll->add($element);
- // If _backRefFieldName is set, then the association is bidirectional
- // and we need to set the back reference.
+ // If _backRefFieldName is set and its a one-to-many association,
+ // we need to set the back reference.
if ($this->_backRefFieldName && $this->_association->isOneToMany()) {
// Set back reference to owner
$this->_typeClass->reflFields[$this->_backRefFieldName]
Index: lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
===================================================================
--- lib/Doctrine/ORM/Persisters/StandardEntityPersister.php (revision 7504)
+++ lib/Doctrine/ORM/Persisters/StandardEntityPersister.php (working copy)
@@ -492,8 +492,8 @@
if ($found = $this->_em->getUnitOfWork()->tryGetById($joinColumnValues, $targetClass->rootEntityName)) {
$this->_class->reflFields[$field]->setValue($entity, $found);
// Complete inverse side, if necessary.
- if (isset($targetClass->inverseMappings[$this->_class->name][$field])) {
- $inverseAssoc = $targetClass->inverseMappings[$this->_class->name][$field];
+ if ($assoc->inversedBy) {
+ $inverseAssoc = $targetClass->associationMappings[$assoc->inversedBy];
$targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($found, $entity);
}
$newData[$field] = $found;
Index: lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
===================================================================
--- lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php (revision 7504)
+++ lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php (working copy)
@@ -87,8 +87,8 @@
if ($assoc->mappedBy) {
$this->_hints['fetched'][$className][$assoc->mappedBy] = true;
} else {
- if (isset($class->inverseMappings[$sourceClassName][$assoc->sourceFieldName])) {
- $inverseAssoc = $class->inverseMappings[$sourceClassName][$assoc->sourceFieldName];
+ if ($assoc->inversedBy) {
+ $inverseAssoc = $class->associationMappings[$assoc->inversedBy];
if ($inverseAssoc->isOneToOne()) {
$this->_hints['fetched'][$className][$inverseAssoc->sourceFieldName] = true;
if ($class->subClasses) {
@@ -346,9 +346,10 @@
$this->_uow->setOriginalEntityProperty($oid, $relationField, $element);
$targetClass = $this->_ce[$relation->targetEntityName];
if ($relation->isOwningSide) {
+ //TODO: Just check hints['fetched'] here?
// If there is an inverse mapping on the target class its bidirectional
- if (isset($targetClass->inverseMappings[$relation->sourceEntityName][$relationField])) {
- $inverseAssoc = $targetClass->inverseMappings[$relation->sourceEntityName][$relationField];
+ if ($relation->inversedBy) {
+ $inverseAssoc = $targetClass->associationMappings[$relation->inversedBy];
if ($inverseAssoc->isOneToOne()) {
$targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($element, $parentObject);
$this->_uow->setOriginalEntityProperty(spl_object_hash($element), $inverseAssoc->sourceFieldName, $parentObject);
Index: UPGRADE_TO_2_0
===================================================================
--- UPGRADE_TO_2_0 (revision 7504)
+++ UPGRADE_TO_2_0 (working copy)
@@ -46,7 +46,7 @@
## Partial Objects
-xxx
+[TBD: New syntax, results, etc.]
## XML Mapping Driver
Index: doctrine-mapping.xsd
===================================================================
--- doctrine-mapping.xsd (revision 7504)
+++ doctrine-mapping.xsd (working copy)
@@ -217,7 +217,7 @@
</xs:complexType>
<xs:complexType name="order-by-field">
- <xs:attribute name="field" type="XS:NMTOKEN" use="required" />
+ <xs:attribute name="name" type="xs:NMTOKEN" use="required" />
<xs:attribute name="direction" type="orm:order-by-direction" default="ASC" />
</xs:complexType>
@@ -237,6 +237,7 @@
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" />
+ <xs:attribute name="inversed-by" type="xs:NMTOKEN" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
</xs:complexType>
@@ -246,7 +247,7 @@
<xs:element name="order-by" type="orm:order-by" minOccurs="0" />
</xs:sequence>
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
- <xs:attribute name="mapped-by" type="xs:NMTOKEN" />
+ <xs:attribute name="mapped-by" type="xs:NMTOKEN" use="required" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
@@ -264,6 +265,7 @@
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
+ <xs:attribute name="inversed-by" type="xs:NMTOKEN" />
</xs:complexType>
<xs:complexType name="one-to-one">
@@ -274,9 +276,10 @@
<xs:element name="join-columns" type="orm:join-columns"/>
</xs:choice>
</xs:sequence>
+ <xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" />
- <xs:attribute name="field" type="xs:NMTOKEN" use="required" />
+ <xs:attribute name="inversed-by" type="xs:NMTOKEN" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
</xs:complexType>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment