drb88830 2016-01-30 12:31
浏览 28

对于同一个子类,DocriminatorMap的不同值的学说

I need to extend a Doctrine Entity with single table inherit with DiscriminatorColumn and DiscriminatorMap from different values to the same subclass.

At the moment I'm trying to do of this way, but just the last value of each Entity was applying. I sought for other ways to do this, with arrays, or collections, but I found nothing in the Doctrine or Symphony Documentation. See the annotation code below:

use Doctrine\ORM\Mapping as ORM;

/**
 * Classe abstrata para definição de um objeto produto
 * 
 * @author Maycon Brito <maycon.brito@rede.bioextratus.rede>
 * @package  models/Doctrine/Entidades
 * @subpackage Produtos
 *
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="codigosubtipo", type="integer")
 * @ORM\DiscriminatorMap({
 *     "3" = "ProdutoAcabado",
 *     "12" = "ProdutoMarketing",
 *     "34" = "ProdutoMarketing",
 *     "36" = "ProdutoEmbalagem", 
 *     "46" = "ProdutoMarketing",
 *     "59" = "ProdutoEmbalagem", 
 *     "60" = "ProdutoEmbalagem", 
 *     "61" = "ProdutoEmbalagem", 
 *     "62" = "ProdutoEmbalagem", 
 *     "81" = "ProdutoEmbalagem", 
 *     "82" = "ProdutoMarketing",
 *     "83" = "ProdutoMarketing",
 *     "84" = "ProdutoMarketing",
 *     "86" = "ProdutoMarketing",
 *     "87" = "ProdutoMarketing",
 *     "89" = "ProdutoMarketing", 
 *     "90" = "ProdutoMarketing",
 *     "91" = "ProdutoMarketing",
 *     "92" = "ProdutoMarketing",
 *     "93" = "ProdutoMarketing",
 *     "94" = "ProdutoMarketing",
 *     "95" = "ProdutoMarketing",
 *     "96" = "ProdutoMarketing",
 *     "97" = "ProdutoMarketing",
 *     "98" = "ProdutoMarketing",
 *     "99" = "ProdutoMarketing",
 *     "100" = "ProdutoMarketing",
 *     "101" = "ProdutoMarketing",
 *     "102" = "ProdutoMarketing",
 *     "103" = "ProdutoEmbalagem", 
 *     "104" = "ProdutoEmbalagem", 
 *     "105" = "ProdutoAcabado",
 *     "107" = "ProdutoAcabado",
 *     "108" = "ProdutoEmbalagem", 
 *     "109" = "ProdutoEmbalagem", 
 *     "111" = "ProdutoEmbalagem", 
 *     "112" = "ProdutoEmbalagem", 
 *     "128" = "ProdutoEmbalagem",
 *     "123" = "ProdutoAcabado",
 *     "106" = "ProdutoMarketing",
 *     "110" = "ProdutoMarketing",
 *     "121" = "ProdutoMarketing",
 *     "125" = "ProdutoTerceirizado",
 *     "126" = "ProdutoMarketing",
 *     "127" = "ProdutoTerceirizado"
 * })
 * @ORM\Table(name="produtos", uniqueConstraints={@ORM\UniqueConstraint(name="id", columns={"id"})}, indexes={@ORM\Index(name="IDX_CodigoSubTipo", columns={"CodigoSubTipo"}), @ORM\Index(name="IDX_CodigoUnidade", columns={"CodigoUnidade"}), @ORM\Index(name="IDX_Volume", columns={"CodigoVolume"}), @ORM\Index(name="IDX_Classe", columns={"CodigoClasse"}), @ORM\Index(name="IDX_CompraAtivada", columns={"CompraAtivada"}), @ORM\Index(name="IDX_Linha", columns={"id_Linha"}), @ORM\Index(name="IDX_LinhaEnvase", columns={"id_LinhaEnvase"}), @ORM\Index(name="idx_Finalidade", columns={"Finalidade"}), @ORM\Index(name="IDX_CodigoProdutoRend", columns={"CodigoProdutoRend"})})
 * @ORM\Entity
 */
abstract class Produto implements InterfaceProduto {

So by example, when I sought for all "ProdutoMarketing" entities the result was just the "ProdutoMarketing" that the value of "codigosubtipo" column was 126.


Another possible Solution:

The discriminatorcolumn (codigosubtipo) is a foreign key of another table (subtipo). This table has a column that isn't an id, but your values are determinats to define the inherited subclass above. If was possible to define the DiscrimnatorColumn of a inner join of a column of another table this problem will be solved.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?