0 votes

Hello, I'm trying to build php classes with orm:generate-entities, it all works well without a namespace
But when I add the 'entidades' namespace, I have the following problem

This is my xml generated with Skipper, "Cartilla,dcm.xml"

<?xml version="1.0"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <entity name="entidades\Cartilla" inheritance-type="SINGLE_TABLE">
    <id name="id" type="integer">
      <generator strategy="AUTO"/>
    </id>
    <many-to-one field="sucursal" target-entity="entidades\Sucursal" inversed-by="cartilla">
      <join-columns/>
    </many-to-one>
    <many-to-one field="nomenclador" target-entity="entidades\Nomenclador" inversed-by="cartilla">
      <join-columns>
        <join-column name="nomenclador_id" referenced-column-name="id"/>
      </join-columns>
    </many-to-one>
    <many-to-one field="coseguro" target-entity="entidades\Coseguro" inversed-by="cartilla">
      <join-columns>
        <join-column name="coseguro_id" referenced-column-name="id"/>
      </join-columns>
    </many-to-one>
    <many-to-one field="plan" target-entity="entidades\Plan" inversed-by="cartilla">
      <join-columns>
        <join-column name="plan_id" referenced-column-name="id"/>
      </join-columns>
    </many-to-one>
    <discriminator-column name="discrimina" length="30" type="string"/>
    <discriminator-map>
      <discriminator-mapping class="entidades\Comedica" value="comedica"/>
      <discriminator-mapping class="entidades\Osadef" value="osadef"/>
    </discriminator-map>
  </entity>
</doctrine-mapping>

This is my bootstrap.php file

<?php

use Doctrine\ORM\Tools\Setup;

require_once "vendor/autoload.php";

$isDevMode = true;

$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/xml"), $isDevMode);

// 
$conn = array(
        'driver' => 'pdo_mysql', //driver de mysql 
        'user' => '', // usuario
        'password' => '', // pass
        'dbname' => 'cartilla', //nombre de la base de datos
        'host' => 'localhost'
);


//gerenciador de entidades
$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);

I get the following error when I run vendor\bin\doctrine.php.bat orm:generate-entities src

[Doctrine\Common\Persistence\Mapping\MappingException]
Invalid mapping file 'Cartilla.dcm.xml' for class 'Cartilla'.

Im on Windows 7 / Xampp / Doctrine 2 / Skipper

Thank you in advance.

in General Questions by (260 points)

I'm not sure if this problem is caused by Skipper or by some external circumstance.
Do you know how to update your Cartilla.dcm.xml file manually to be valid for Doctrine?

How looks generated files for Comedica and Osadef? Maybe the problem is caused by inheritance. Can you try to remove inheritance, export it again and try to cal generate-entities again please?

1 Answer

0 votes

Hi ludk.vodicka thanks for your quick response, look I generated a new xml "Pais.dcm.xml"

<?xml version="1.0"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <entity name="entidades\Pais">
    <id name="id" type="integer">
      <generator strategy="AUTO"/>
    </id>
    <field name="nombre" type="string" length="65" nullable="true"/>
  </entity>
</doctrine-mapping>

I get the same error, this time with no inheritance, no relations,

If i just remove entidades/ from the xml, it generates the entity, but then i won't have the entity on a namespace.

I think i'm doing something wrong but I can't understand it, the message "invalid mapping" is just too vague. Greetings.

by (260 points)