【问题标题】:Mapping entities in XML at Symfony2 + Doctrine在 Symfony2 + Doctrine 中用 XML 映射实体
【发布时间】:2014-06-30 18:49:40
【问题描述】:

我正在从事一个通过 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 映射中的某些内容?有什么帮助吗?

我读过 thisthis 但这根本无法消除我的疑问

【问题讨论】:

    标签: xml symfony doctrine-orm mapping


    【解决方案1】:

    好吧,我会回答自己,因为没有人回答。答案是“是”,需要创建文件,因为 XML 映射与 Annotation 映射的作用相同,以便描述字段、列、关系定义等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 1970-01-01
      • 2020-01-27
      • 2016-01-20
      • 1970-01-01
      相关资源
      最近更新 更多