i use doctrine ORM for generate a association one-to-many bidirectional, but when i execute the orm:validation-scheme command, this shows me the mesaje below:
"C:\xampp\htdocs\Gestor\vendor\bin>doctrine-module orm:validate-schema [Mapping] FAIL - The entity-class 'Empleados\Entity\TipoDocumento' mapping is i nvalid: * The association Empleados\Entity\TipoDocumento#empleados refers to the owning side field Empleados\Entity\Empleado#tipodocumento which does not exist.
[Database] FAIL - The database schema is not in sync with the current mapping fi le."
The code: Empleado class (many to one side)
<?php
namespace Empleados\Entity;
use Doctrine\Common\Collections\ArrayCollection as Collection;
use Empresas\Entity\Empresa;
use Empleados\Entity\TipoDocumento;
use Doctrine\ORM\Mapping as ORM;
use Documentos\Entity\Documentacion_Empleado;
/**
* @ORM\Entity
* @ORM\Table(name="empleado")
*
*/
class Empleado
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string",length=30,nullable=false,unique=true)
*/
private $nro_documento;
/*
* @ORM\ManyToOne(targetEntity="Empleados\Entity\TipoDocumento",inversedBy="empleados")
* @ORM\JoinColumn(name="tipodocumento_id", referencedColumnName="id")
*/
private $tipodocumento;
//...
}
The TipoDocumento class (one to many side):
<?php
// yes, the class are in the same namespace "Empleados"
namespace Empleados\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Empleados\Entity\Empleado;
/**
* @ORM\Entity
* @ORM\Table(name="tipo_documento")
*/
class TipoDocumento
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity="Empleados\Entity\Empleado", mappedBy="tipodocumento"))
*/
private $empleados;
//.....
public function __construct()
{
$this->empleados = new ArrayCollection();
}
}
I'm based on the Doctrine documentation example in http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html
use Empresas\Entity\Empresa,use Empleados\Entity\TipoDocumento) and see if you get the same error. - jmarkmurphy