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