So I was working with doctrine multiple class table inheritance with an existing database. When I tried to query it throws

The discriminator column "customertype" is missing for "Entity\Customer" using the DQL alias "r".

The current entity setup is as follows:

I have an abstract class Customer where the discriminator column is defined.

<?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...
}

The child Merchant class...

<?php

namespace Entity\Customer;

use {included all imports}

/**
 * Merchant
 *
 * @ORM\Table(name="public.`CustomerMerchant`")
 * @ORM\Entity
 */
class Merchant extends Customer
{

}

The child Affiliate class...

namespace Entity\Customer;

use {included all imports}

/**
 * CustomerAffiliate
 *
 * @ORM\Table(name="public.`CustomerAffiliate`")
 * @ORM\Entity
 */
class Affiliate extends Customer
{
}

I know the problem is on the discriminator column having a camelCased and not quoted format but maybe anyone had the same problem and created a work around with this.

0

There are 0 best solutions below