When running orm:schem-tool:update, I get this error:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@Doctrine\Orm\Mapping\ManyToMany" in property Admin\Entity\AppointmentDefinition::$products does not exist, or could not be auto-loaded.
I've been searching already all over Stackoverflow for why this happens but I haven't found anything yet. It seems to work for @ORM\OneToMany or @ORM\ManyToOne annotations. I also get the same error for @ORM\JoinTable.
Here is my entity class:
namespace Admin\Entity;
use Doctrine\Orm\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection as ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity
* @ORM\Table(name="appointment_definition")
*/
class AppointmentDefinition
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var integer
*
* @ORM\Column(type="integer", nullable=false)
*/
protected $timeLength;
/**
* @var string
*
* @ORM\Column(type="string", length=200, nullable=false)
*/
protected $name;
/**
* @var object ArrayCollection
*
* @ORM\ManyToMany(targetEntity="Admin\Entity\Product")
* @ORM\JoinTable(name="appointment_definition_product",
* joinColumns={@ORM\@JoinColumn(name="appointment_definition_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\@JoinColumn(name="product_id", referencedColumnName="id")}
* )
*/
protected $products;
/**
* @var \DateTime
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt;
/**
* @var \DateTime
*
* @Gedmo\Timestampable(on="update")
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
private $updatedAt;
/**
* @var \DateTime
*
* @ORM\Column(name="deleted_at", type="datetime", nullable=true)
*/
private $deletedAt;
public function __construct()
{
$this->products = new ArrayCollection();
}
/**
* Get id
*
* @return void
*/
public function getId()
{
return $this->id;
}
/**
* Get timelength
*
* @return int
*/
public function getTimeLength()
{
return $this->timeLength;
}
/**
* Set timelength
*
* @param int $timeLength
* @return self
*/
public function setTimeLength($timeLength)
{
$this->timeLength = $timeLength;
return $this;
}
/**
* Get appointment definition name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set appointment definition name
*
* @param string $name
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get createdAt
*
* @return datetime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Get updatedAt
*
* @return datetime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Get deletedAt
*
* @return datetime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set deletedAt
*
* @param integer $deletedAt
* @return self
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get products
*
* @return object ArrayCollection
*/
public function getProducts()
{
return $this->products;
}
/**
* Add products
*
* @param array|ArrayCollection $products
* @return self
*/
public function addProducts($products)
{
foreach($products as $product) {
$this->addProduct($product);
}
return $this;
}
/**
* Add product
*
* @param object $product
* @return self
*/
public function addProduct(Product $product)
{
$this->products->add($product);
return $this;
}
/**
* Remove product
*
* @param object $product
* @return self
*/
public function removeProduct(Product $product)
{
$this->products->removeElement($product);
return $this;
}
/**
* Remove products
*
* @param array|ArrayCollection $products
* @return self
*/
public function removeProducts($products)
{
$this->products->removeProduct($products);
return $this;
}
}
Can someone please point what I'm doing wrong here?