[英]Mapping entities in XML at 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
,將其作為輸出:
[Doctrine \\ Common \\ Persistence \\ Mapping \\ MappingException]
類“ TaxiBooking \\ Device \\ DeviceBundle \\ Entity \\ Device”不存在
是的,沒錯,該文件不存在,但是我應該創建該文件還是錯過XML映射中的某些內容? 有什么幫助嗎?
好吧,我會回答自己的,因為沒人會回答。 答案是“是”,因為描述字段,列,關系定義等的XML映射與注釋映射完全相同,所以需要創建文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.