1
votes

I have the entity:

/**
 * @ORM\Entity
 * @ORM\Table(name="TERCEROS")
 */
class Empleado
{
    /**
     * @ORM\Id
     * @ORM\Column(type="string", name="CODIGO", length=15)
     * @ORM\GeneratedValue(strategy="NONE")
     * @var string
     */
    protected $cedula;

    /**
     * @ORM\Column(type="string", name="APELLIDO1")
     * @var string
     */
    protected $apellido1;
}

and so get the manager:

$path = array(__DIR__.'/../../Entities');
$devMode = getenv('DEV_MODE');
$config = Setup::createAnnotationMetadataConfiguration($path, $devMode, null, null, false);

$config->setProxyDir($path[0] . '/Proxy');
$config->setProxyNamespace('Proxy');

$empleadosManager = \Doctrine\ORM\EntityManager::create(arrayparams, $config);

when using any method find which should return one single Empleado this return null

$empleadosRepository = $empleadosManager->getRepository(Empleado::class);
$empleados = $empleadosRespository->findAll(); //this returns the data correctly
$empleado = $empleados = $empleadosRespository->find('12345678'); //=null
$empleado = $empleados = $empleadosRespository->findOneBy(['apellido1' =>'fulano']); //=null

None are found, even though I have an Empleado with apellido1 = 'fulano' and cedula = '1234567' inserted in the database

PS: I am working with doctrine outside of Symfony.

1

1 Answers

0
votes

All looks fine to me but it could be that you ran into a upper/lower case issue here. It seems you have all table and column names capitalized.

Are the table names and the column names in entity declaration correct? It seems a bit inconsistent:

table: TERCEROS (Should this not be EMPLEADO??)
column: CODIGO (Should this not be CEDULA??)

Because of this you might be querying the wrong table/column...!?