2

I'm using doctrine to generate the entities from database in command line

doctrine orm:convert-mapping --force --from-database annotation ./Api/Entity

The php class is created correctly but when i try to use the repository to load the entity from the database

$decompte=$entityManager->getRepository(Decompte::class)->find(31);

I'm getting this exception

Class "entity\Decompte" is not a valid entity or mapped super class.

and please find above the entire code of the class entity\Decompte

<?php

use Doctrine\ORM\Mapping as ORM;

/**
 * Decompte
 *
 * @ORM\Table(name="decompte", indexes={@ORM\Index(name="N°D", columns={"ID"})})
 * @ORM\Entity
 */
class Decompte
{
    /**
     * @var int
     *
     * @ORM\Column(name="ID", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var int|null
     *
     * @ORM\Column(name="NPRIXD", type="integer", nullable=true)
     */
    private $nprixd;

    /**
     * @var string|null
     *
     * @ORM\Column(name="DESIGNATIOND", type="string", length=43, nullable=true)
     */
    private $designationd;

    /**
     * @var string|null
     *
     * @ORM\Column(name="UNITED", type="string", length=2, nullable=true)
     */
    private $united;

    /**
     * @var int|null
     *
     * @ORM\Column(name="QTED", type="integer", nullable=true)
     */
    private $qted;

    /**
     * @var int|null
     *
     * @ORM\Column(name="PRIXHTD", type="integer", nullable=true)
     */
    private $prixhtd;

    /**
     * @var string|null
     *
     * @ORM\Column(name="DECOMPTED", type="string", length=2, nullable=true)
     */
    private $decompted;

    /**
     * @var int|null
     *
     * @ORM\Column(name="TOTALD", type="integer", nullable=true)
     */
    private $totald;

    /**
     * @var string|null
     *
     * @ORM\Column(name="QMARCHE", type="string", length=11, nullable=true)
     */
    private $qmarche;

    /**
     * @var string|null
     *
     * @ORM\Column(name="QDECOMPTE", type="string", length=5, nullable=true)
     */
    private $qdecompte;

    /**
     * @var int|null
     *
     * @ORM\Column(name="SMARCHE", type="integer", nullable=true)
     */
    private $smarche;

    /**
     * @var string|null
     *
     * @ORM\Column(name="SDECOMPTE", type="string", length=6, nullable=true)
     */
    private $sdecompte;

    /**
     * @var int|null
     *
     * @ORM\Column(name="NDMR", type="integer", nullable=true)
     */
    private $ndmr;

    /**
     * @var string|null
     *
     * @ORM\Column(name="RESTE", type="string", length=11, nullable=true)
     */
    private $reste;

    /**
     * @var string|null
     *
     * @ORM\Column(name="RESTEF", type="string", length=11, nullable=true)
     */
    private $restef;


}

when trying to debug this issue, i found out that the Annotation Driver reader's cache is empty

i've added somme "echo" in the AnnotationDriver::loadMetaDataForClass

 echo 'allClassName'.$this->getAllClassNames();
    echo 'allPaths'.$this->getPaths();
    returns an empty array


$classAnnotations = $this->reader->getClassAnnotations($class);
is also empty

thank you very much for you help

Jelti M
  • 21
  • 2
  • This might help https://stackoverflow.com/questions/19144603/doctrine-class-is-not-a-valid-entity-or-mapped-super-class – ROOT Jan 08 '20 at 07:23
  • Hello, show your complete Decompte class code to solve your problem. Check for @ORM \ Entity annotation on class – Aleksandr Jan 08 '20 at 13:27
  • Thank you @mamounothman but i don't think that my problem is the same because my class definition seems correct – Jelti M Jan 08 '20 at 22:12
  • @Aleksandr any idea? – Jelti M Jan 09 '20 at 15:38
  • your index name look weird – olidem Jan 10 '20 at 15:20
  • thanks @olidem, i modified that but the problem is still present – Jelti M Jan 11 '20 at 13:25
  • Is your namespace declaration left-out on purpose? Doctrine is configured by default to look in specific directories for the entities, unless it's changed. – Artamiel Jan 11 '20 at 13:53
  • Are you working in a symfony context? If not, try that. You can just checkout their demo application and put your entity there. I think your doctrine initialization has a bug somewhere. Does any other entity work? – olidem Jan 13 '20 at 23:44

0 Answers0