0

I'm searching why I get an error with my mapping but, I really don't see. I red some issues in stack but it doesn't work for me.

The error : The association CTC\Bundle\UserBundle\Entity\Address#addressType refers to the inverse side field CTC\Bundle\AdminBundle\Entity\AddressType#addresses which does not exist.

Secondly, I also wonder me why when I use my "doctrine:generate:entities ...", that doesn't give me the getter and setter for addresses but well for addressType.

Here is my mapping code :

class AddressType

...

/*
     * @var array
     * 
     * @ORM\OneToMany(targetEntity="CTC\Bundle\UserBundle\Entity\Address", mappedBy="addressType")
     *
     */
    private $addresses;


    public function __construct()
    {
        $this->addresses = new ArrayCollection();
    }
...

Class Address

/**
     * @ORM\ManyToOne(targetEntity="CTC\Bundle\AdminBundle\Entity\AddressType", inversedBy="addresses")
     * @ORM\JoinColumn(name="addressTypeID", referencedColumnName="AddressTypeID")
     */
    private $addressType;

Any help would be very appreciate.

Benjamin Lucas
  • 370
  • 5
  • 20

2 Answers2

1

Ok, It was just a problem of * !

In the AddressType class, I change this

/*
* @var array
* 
* @ORM\OneToMany(targetEntity="CTC\Bundle\UserBundle\Entity\Address", mappedBy="addressType")
*
*/
private $addresses;

by this

I just add ONE "" after "/" and everything works !

/**
* @var array
* 
* @ORM\OneToMany(targetEntity="CTC\Bundle\UserBundle\Entity\Address", mappedBy="addressType")
*
*/
private $addresses;
Benjamin Lucas
  • 370
  • 5
  • 20
0
    /*
         * @var array
         * 
         * @ORM\OneToMany(targetEntity="CTC\Bundle\UserBundle\Entity\Address", mappedBy="addressType", cascade={"persist","remove"})
         *
         */
        private $addresses;


        public function __construct()
        {
            $this->addresses = new ArrayCollection();
        }


/**
     * @ORM\ManyToOne(targetEntity="CTC\Bundle\AdminBundle\Entity\AddressType", inversedBy="addresses")
     * @ORM\JoinColumn(name="addressTypeID", referencedColumnName="id")
     */
    private $addressType;

I think your property name for Id inside addressType entity is not AddressTypeID , I cann't write commit to ask this :( I hope this work phone you

Farshadi
  • 143
  • 1
  • 12