2013-02-15 80 views
0

我剛剛將Symfony的項目版本從2.1升級到2.2 RC2,並開始看到一些映射錯誤沒有出現在2.1上。我的整個映射似乎會引發錯誤。有一個例子:升級到Symfony 2.2 RC2導致映射錯誤

這些是我的兩個實體。

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 
     [...] 

這些都是我得到的錯誤:

協會MyBundle \實體\ Usuario#historicos指 擁有方字段MyBundle \ Entity \ Historico#id未定義爲 關聯。

協會MyBundle \ Entity \ Usuario#historicos將 指向擁有方的字段MyBundle \ Entity \ Historico#id,其中不存在 。

我以前composer.json(從2.1版本,在一切都很好工作)有這些版本的學說:

[...] 
"doctrine/orm": ">=2.2.3,<2.4-dev", 
"doctrine/doctrine-bundle": "1.0.*", 
[...] 

而且Symfony的2.2 RC2附帶這些版本的教義:

[...] 
"doctrine/orm": "~2.2,>=2.2.3", 
"doctrine/doctrine-bundle": "1.2.*", 
[...] 

我不確定我做錯了什麼,它看起來非常像我們在doctrine的映射文檔中看到的一切。如果有人能指引我走向正確的方向,那會很棒。

回答

2

驗證錯誤是正確的。

這沒有什麼錯:我們只是改進了Doctrine的運行時驗證器,以便在加載元數據時也捕獲這些異常。

下面是你的YAML實際上應改爲:

MyBundle\Entity\Usuario: 
    [...] 
    oneToMany: 
     historicos: 
      targetEntity: Historico 
      mappedBy: coUsuario 
    [...] 

我基本上是固定的oneToMany協會mappedBy酒店在正確的場點。

相關問題