映射彼此不一致。单表继承

时间:2014-01-04 21:22:11

标签: symfony inheritance doctrine-orm mapping single-table-inheritance

我在Symfony的分析器中遇到了很多映射错误。 我只与表继承超类的关联有这个问题。 所有其他实体和关系都很好并且工作得很好。

错误:

***\ArticleBundle\Entity\Article    
The mappings ***\ArticleBundle\Entity\Article#buyer and ***\UserBundle\Entity\User#boughtArticles are inconsistent with each other.
The association ***\ArticleBundle\Entity\Article#category refers to the inverse side field ***\ArticleBundle\Entity\Category#article which does not exist.
The association ***\ArticleBundle\Entity\Article#tags refers to the inverse side field ***\ArticleBundle\Entity\Tag#article which does not exist.

***\ArticleBundle\Entity\TBA    
The mappings ***\ArticleBundle\Entity\TBA#buyer and ***\UserBundle\Entity\User#boughtArticles are inconsistent with each other.
The association ***\ArticleBundle\Entity\TBA#category refers to the inverse side field ***\ArticleBundle\Entity\Category#article which does not exist.
The association ***\ArticleBundle\Entity\TBA#tags refers to the inverse side field ***\ArticleBundle\Entity\Tag#article which does not exist.

文章实体:

/**
 * Article
 *
 * @ORM\Table("articles")
 * @ORM\Entity(repositoryClass="***\ArticleBundle\Entity\ArticleRepository")
 * @ORM\HasLifecycleCallbacks
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="article_type", type="string")
 * @ORM\DiscriminatorMap({"auction" = "Auction", "fixed" = "Fixed", "tba" = "TBA"})
 */
class Article
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="***\UserBundle\Entity\User", inversedBy="articles")
     **/
    protected $user;

    /**
     * @ORM\ManyToOne(targetEntity="***\UserBundle\Entity\User", inversedBy="boughtArticles")
     **/
    protected $buyer;

    /**
     * @ORM\ManyToOne(targetEntity="Category", inversedBy="article")
     **/
    protected $category;

    /**
     * @ORM\ManyToMany(targetEntity="Tag", inversedBy="article")
     * @ORM\JoinTable(name="article_has_tags")
     **/
    protected $tags;

用户实体

/**
 * User
 *
 * @ORM\Table(name="users")
 * @ORM\HasLifecycleCallbacks
 * @ORM\Entity(repositoryClass="Snuffelmarkt\UserBundle\Entity\UserRepository")
 * @UniqueEntity(fields="username", message="De door u ingevulde gebruikersnaam is al in gebruik")
 * @UniqueEntity(fields="email", message="Er bestaat al een gebruiker met het door u ingevoerde emailadres")
 */
class User implements UserInterface, Serializable
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\OneToMany(targetEntity="Snuffelmarkt\ArticleBundle\Entity\Article", mappedBy="user")
     **/
    protected $articles;

    /**
     * @ORM\OneToMany(targetEntity="Snuffelmarkt\ArticleBundle\Entity\Article", mappedBy="user")
     **/
    protected $boughtArticles;

    /**
     * @ORM\OneToOne(targetEntity="Profile", mappedBy="user")
     */
    private $profile;

0 个答案:

没有答案