I
I
Igor Katkov2015-09-21 15:48:24
symfony
Igor Katkov, 2015-09-21 15:48:24

What is the reason for the "Class Foo is not a valid entity or mapped super class." error?

Good day!
There is an essence

<?php

namespace Main\CatalogBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="Main\CatalogBundle\Repository\ShopCategoriesRepository")
 * @ORM\Table(name="shop_categories")
 */
class ShopCategories
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     *@ORM\Column(type="integer", name="shop_id")
     */
    private $shopId;

    /**
     * @ORM\Column(type="string")
     */
    private $name;

    /**
     * @ORM\Column(type="integer", name="category_id")
     */
    private $categoryId;

    /**
     * @ORM\Column(type="integer")
     */
    private $parent;

    /**
     * @ORM\Column(type="smallint")
     */
    private $status;

    /**
     * @ORM\Column(type="integer", name="total_products")
     */
    private $totalProducts;

    /**
     * @ORM\Column(type="integer", name="unknown_products")
     */
    private $unknownProducts;

    /**
     * @ORM\Column(type="intger", name="false_products")
     */
    private $falseProducts;


}

An error occurs when attempting to generate an entity
[Doctrine\ORM\Mapping\MappingException]
Class "Main\CatalogBundle\Entity\ShopCategories" is not a valid entity or
mapped super class.

Where to dig?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis, 2015-09-21
@iKatkovJS

This exception is thrown by DisconnectedMetadataFactory and Driver/*Driver.
Most likely the problem is not in the first.
Also note that only ONE format is supported. Annotations, yml, xml...
There should be nothing in the Main/CatalogBundle/Resources/doctrine/ folder if you use annotations.
https://github.com/symfony/symfony/issues/4554

E
Egor, 2015-09-21
@want2know

First, you are describing something wrong. Where are the connections? What's the shopId, categoryId, parent? Read about association mapping
Secondly:

/**
* @ORM\Column(type="intger", name="false_products")
*/
private $falseProducts;
here intgerand needinteger

A
Alexey Romanenko, 2015-09-21
@slimus

What do you have in config.yml in the doctrine section?
stackoverflow.com/questions/20887211/how-to-fix-cl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question