Wondering if anybody else has run into this issue. In summary, we upgraded from Symfony 2.0 to Symfony 2.1. With Symfony 2.1 if a create a brand new bundle and then an entity to use with Doctrine I get a "not a valid entity or mapped super class"
. If I place the same exact entity class (with proper path changes) into an existing bundle (created before 2.1) it can be accessed with no problems, even from the new bundle.
Here are the steps.
$ php app/console generate:bundle --namespace="Core/TestBundle"--format=yml --no-interaction --structure=no --dir=src
$ php app/console doctrine:generate:entity --entity="CoreTestBundle:Product" --fields="name:string(255) price:float description:text"
here is the Product.php code produced
<?php
namespace Core\TestBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Core\TestBundle\Entity\Product
*
* @ORM\Table()
* @ORM\Entity
*/
class Product
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var float $price
*
* @ORM\Column(name="price", type="float")
*/
private $price;
/**
* @var text $description
*
* @ORM\Column(name="description", type="text")
*/
private $description;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Product
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set price
*
* @param float $price
* @return Product
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return float
*/
public function getPrice()
{
return $this->price;
}
/**
* Set description
*
* @param text $description
* @return Product
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return text
*/
public function getDescription()
{
return $this->description;
}
}
from here running
$ php app/console doctrine:generate:entities "Core/TestBundle/Entity/Product"
or accessing Product from code runs into[Doctrine\ORM\Mapping\MappingException] Class
Core\TestBundle\Entity\Product is not a valid entity or mapped super
class.
running$ php app/console doctrine:schema:update --force
produces "Nothing to update"
On the other hand, if I use a pre-existing bundle such as ArticleBundle and run the same commands ie
$ php app/console doctrine:generate:entity --entity="CoreArticleBundle:Product" --fields="name:string(255) price:float description:text"
$ php app/console doctrine:generate:entities "Core/ArticleBundle/Entity/Product"
$ php app/console doctrine:schema:update --force
creates the table fine
Also, accessing the Product from the TestBundle as CoreArticleBundle:Product
works fine.
I tried to compare the bundle configurations etc but couldn't come up with anything.
I also run the db creation scripts as follows.
$ php app/console doctrine:database:drop --force
Dropped database for connection named dev
$ php app/console doctrine:database:create
Created database for connection named dev All the tables got created except for the Product one.
In addition I created a fixture with the Product object. Same thing. Works when in an existing bundle. Same error as above in the newly created bundle.