'Doctrine ReflectionException property does not exist

I'm trying to add Doctrine on top of an existing database. I let Doctrine generate annotated entities and adjusted from there. When I try to load the entity below I get the error PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Property Users\\User::$resellerID does not exist'

class User
{
    /* ... */

    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToOne(targetEntity="\Resellers\Reseller")
     * @ORM\JoinTable(name="reseller",
     *   joinColumns={
     *     @ORM\JoinColumn(name="resellerID", referencedColumnName="resellerID")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="resellerID", referencedColumnName="resellerID")
     *   }
     * )
     */
    private $reseller;

    /* ... */
}

Both the user and reseller tables have resellerID columns. My understanding is that for joining ID columns you don't add the ID columns as properties in the entity class. So what's causing the ReflectionException?



Solution 1:[1]

For me clearing the PHP APC cache was the solution

<?php
apc_clear_cache();

Solution 2:[2]

Anyway, it helped me

php artisan  doctrine:clear:metadata:cache

Solution 3:[3]

Usually on production you want something like this:

php bin/console doctrine:cache:clear-result --env=prod
php bin/console doctrine:cache:clear-query --env=prod
php bin/console doctrine:cache:clear-metadata --env=prod

Solution 4:[4]

My error still occurred when I attempted to clear the doctrine cache.

What worked for me was to manually clear the cache by deleting the folder under /storage/framework/cache/*

Solution 5:[5]

In Symfony, due to Docker container permissions, I had to manually delete everything under /var/cache/.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Alenko Verzina
Solution 3 Jeffrey L. Roberts
Solution 4 TwistedSt
Solution 5 user13859151