Reputation: 2125
I have just upgraded my Symfony's project version from 2.1 to 2.2 RC2 and started seeing some mapping errors that did not appear on 2.1. My entire mapping seems to throw errors. There's an example:
These are my two entities.
1.
MyBundle\Entity\Usuario:
type: entity
table: usuario
id:
id:
type: integer
generator: { strategy: AUTO }
column: co_usuario
fields:
[...]
oneToMany:
historicos:
targetEntity: Historico
mappedBy: id
[...]
2.
MyBundle\Entity\Historico:
type: entity
table: historico
id:
id:
type: integer
generator: { strategy: AUTO }
column: co_historico
fields:
[...]
manyToOne:
coUsuario:
targetEntity: Usuario
inversedBy: historicos
joinColumn:
name: co_usuario
referencedColumnName: co_usuario
[...]
And these are the errors I'm getting:
The association MyBundle\Entity\Usuario#historicos refers to the owning side field MyBundle\Entity\Historico#id which is not defined as association.
The association MyBundle\Entity\Usuario#historicos refers to the owning side field MyBundle\Entity\Historico#id which does not exist.
My previous composer.json (from version 2.1, in which everything was working fine) had these versions of doctrine:
[...]
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.0.*",
[...]
And Symfony 2.2 RC2 comes with these versions of Doctrine:
[...]
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "1.2.*",
[...]
I'm not sure what I'm doing wrong, it seems pretty much like everything we see on doctrine's mapping docs. If someone could point me in the right direction, that would be great.
Upvotes: 0
Views: 290
Reputation: 25431
The validation error is right.
There's nothing wrong with that: we just improved Doctrine's runtime validator to catch such exceptions also when metadata is loaded.
Here's how your YAML should actually be changed:
MyBundle\Entity\Usuario:
[...]
oneToMany:
historicos:
targetEntity: Historico
mappedBy: coUsuario
[...]
I basically fixed the oneToMany
association mappedBy
property to point at the correct field.
Upvotes: 2