2014-06-30 59 views
0

我正在研究一個項目,其中實體映射是低谷的XML。因此,這是我的實體是如何:用Symfony2 + Doctrine在XML中映射實體

<?xml version="1.0" encoding="UTF-8"?> 
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" 
        xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping 
        http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> 

    <entity name="Device\DeviceBundle\Entity\Device" table="device"> 
     <id name="id" type="integer" column="id"> 
      <generator strategy="AUTO" /> 
     </id> 
     <field name="description" column="description" type="string" length="255" unique="true" nullable="false" /> 
     <field name="imei" column="imei" type="string" length="17" unique="true" nullable="false" /> 
     <field name="created" type="datetime"> 
      <gedmo:timestampable on="create"/> 
     </field> 
     <field name="modified" type="datetime"> 
      <gedmo:timestampable on="update"/> 
     </field> 
     <field name="deletedAt" type="datetime" nullable="true" /> 
     <gedmo:soft-deleteable field-name="deletedAt" time-aware="false" /> 
    </entity> 
</doctrine-mapping> 

當我從Symfony2的控制檯中運行命令doctrine:schema:validate我得到這樣的輸出:

[主義\ COMMON \持久性\製圖\ MappingException]
類'TaxiBooking \ Device \ DeviceBundle \ Entity \ Device'不存在

是的,這是正確的文件不存在,但我應該創建這個文件或我想念XML映射中的東西?任何幫助?

我讀thisthis但是,這並不在所有

回答

0

清除我的疑問嗯,因爲沒有做我會回答自己。答案是「YES」,因爲XML映射只是和Annotation映射一樣做,所以需要創建該文件,以便描述字段,列,關係定義等等。