Hi everyone,

I'm new to Doctrine and that's my first post to this group, so I hope I can 
clearly explain my problem. 

I have a DB model already created (by someone else) from which I'm modeling 
my Doctrine entities; I'm beginning to understand the different relation 
related annotations and I've already created most of the entities. I have, 
however, a problem with the DB structure shown in the image:


<https://lh5.googleusercontent.com/-kwxf0b1QYUU/VLljrG8n43I/AAAAAAAABpk/xLblfbbx0-4/s1600/relation.png>



I've already created the Many to Many "CommissionPays" table by using 
annotations:

/**
 * @var \Doctrine\Common\Collections\Collection
 *
 * @ORM\ManyToMany(targetEntity="Pays", inversedBy="commissionId")
 * @ORM\JoinTable(name="CommissionPays",
 *   joinColumns={
 *     @ORM\JoinColumn(name="commissionID", 
referencedColumnName="commissionID", nullable=false)
 *   },
 *   inverseJoinColumns={
 *     @ORM\JoinColumn(name="paysCode", referencedColumnName="paysCode", 
nullable=false)
 *   }
 * )
 */
private $paysCodes;



 However, now that I need to create the "CommissionRegion" table (see 
image), I'm trying in the annotations to refer to the fields "commissionId" 
and "paysCode" belonging to the intermediate "CommissionPays" table:

 
 

/**
 * @var \Commission
 *
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="NONE")
 * @ORM\ManyToOne(targetEntity="CommissionPays")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="commissionID", referencedColumnName="commissionID", 
nullable=false)
 * })
 */
private $commissionId;

/**
 * @var \Pays
 *
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="NONE")
 * @ORM\ManyToOne(targetEntity="CommissionPays")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="paysCode", referencedColumnName="paysCode", 
nullable=false)
 * })
 */
private $paysCode;



Doctrine gives this error:


*[Doctrine\ORM\Mapping\MappingException]                                        
                                                                   
  The target-entity Cenr\ReligionAppBundle\Entity\CommissionPays cannot be 
found in 'Cenr\ReligionAppBundle\Entity\CommissionRegion#commissionId'.  *

which is very understandable giving that the  "CommissionPays" entity does 
not exist because Doctrine is generating automatically the intermediate 
table. 

Is there any way to refer to the fields belogning to an intermediate table 
in the annotations of an entity? If not, what are the options? It is 
possible to just create the "CommissionRegion" entity without annotations 
and to make manually the required joins in a controller when necessary?  By 
the way, I'm working with Symfony 2.6 and the latest doctrine version. 


 Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to