所以我正在使用现有数据库的多类表继承学说。当我试图查询它抛出
使用 DQL 别名“r”的“Entity\Customer”缺少鉴别器列“customertype”。
当前实体设置如下:
我有一个抽象类 Customer,其中定义了鉴别器列。
<?php
namespace Entity;
use {included all imports}
Entity\Postgres\Customer\CompanyCustomer;
/**
* Customer
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorMap({
* 1="Entity\Customer\Merchant",
* 2="Entity\Customer\Affiliate"
* })
* @ORM\Entity(repositoryClass="Repository\CustomerRepository")
* @ORM\Table(name="public.`Customer`")
* @ORM\DiscriminatorColumn(name="customerType", type="smallint")
* @JMS\Discriminator(field="customerType", map = {
* 1="Entity\Customer\Merchant",
* 2="Entity\Customer\Affiliate"
* })
* @JMS\ExclusionPolicy("all")
*/
abstract class Customer implements EntityInterface
{
protected $id;
more properties...
and methods...
}
小商人班...
<?php
namespace Entity\Customer;
use {included all imports}
/**
* Merchant
*
* @ORM\Table(name="public.`CustomerMerchant`")
* @ORM\Entity
*/
class Merchant extends Customer
{
}
儿童附属班级...
namespace Entity\Customer;
use {included all imports}
/**
* CustomerAffiliate
*
* @ORM\Table(name="public.`CustomerAffiliate`")
* @ORM\Entity
*/
class Affiliate extends Customer
{
}
我知道问题出在鉴别器列上,它的格式为驼峰式,但没有引用格式,但也许任何人都有同样的问题,并为此创建了一个解决方法。