0 votes

I tried a Many-to-Many association but I found different issues :

  • my Entities were in different modules, each of them having a different namespace, but this information didn't appear in the Doctrine Annotation export

  • I added properties to the association but they didn't appear in the export. In fact they couldn't appear because if I'm not wrong Doctrine can't manage Many-to-Many associations having properties. Instead, a new Entity should be created with 2 different Many-to-One associations. But maybe I missed something?

in Solved by (480 points)
edited by

Regarding to first question: Could you please send us testing case where this issue happens, so we can test it and fix it? Thanks.

Regarding to second question: You have to define it manually, ORM Designer doesn't do any additional logic/transformation on your defined model. If you need two associations and entity, just define it ;-).

Next time please fill what platform (Win / Lin / Mac) and ORM (Doctrine/Doctrine2) are you using. In your case I suppose you're using Doctrine2 because of annotations.

2 Answers

0 votes
Best answer

Fixed in version 2.1.9. Download it here: http://www.orm-designer.com/download-orm-designer

by Skipper developer (141k points)
selected by
0 votes

Sorry.
I'm on Win, exporting to Symfony2 / Doctrine2 annotations.

Here's a screenshot of a simple test (It seems I can't send the ormdesigner2 using this interface, but I can send it by email)
Image caption

Here's the generated code :

<?php    
namespace Sedona\Main;
use Doctrine\ORM\Mapping AS ORM;

/** 
 * @ORM\Entity
 */
class SampleEntity
{
  /** 
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;

  /** 
   * @ORM\Column(type="string", length=255, nullable=true)
   */
  private $name;

  /** 
   * @ORM\ManyToMany(targetEntity="OtherEntity", inversedBy="SampleEntities")
   * @ORM\JoinTable(
   *   name="OtherEntityHasSampleEntity", 
   *   joinColumns={@ORM\JoinColumn(name="sample_entity_id", referencedColumnName="id", nullable=false)}, 
   *   inverseJoinColumns={@ORM\JoinColumn(name="other_entity_id", referencedColumnName="id", nullable=false)}
   * )
   */
  private $OtherEntities;
}

and

<?php
namespace Sedona\Second;
use Doctrine\ORM\Mapping AS ORM;

/** 
 * @ORM\Entity
 */
class OtherEntity
{
  /** 
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;

  /** 
   * @ORM\ManyToMany(targetEntity="SampleEntity", mappedBy="OtherEntities")
   */
  private $SampleEntities;
}

Problems :
- In the targetEntity and inversedBy annotations, the namespace should be added
- I don't see anywhere my "myassociationfield" placed in the ManyToMany association

by (480 points)

Thank you for detailed post.

Issue with many-to-many entity namespace will be fixed for next release.

Regarding to your question about "my association field". Doctrine2 doesn't allow to define any additional fields inside MN entities. If you want to store any additional data, you need to define MN association and entity manually as two separated associations.