1

I've created a new entity in src/Andrei/StatisticsBundle/Entity/Attribute/Value/ButtonVarchar.php. Here is the code for this class:

<?php

namespace Andrei\StatisticsBundle\Entity\Attribute\Value;

class ButtonVarchar
{
    protected $value;
}

and in src/Andrei/StatisticsBundle/Resources/config/doctrine/ButtonVarchar.yml I defined the following mapping information:

Andrei\StatisticsBundle\Entity\Attribute\Value\ButtonVarchar:
    type: entity
    table: button_attribute_value_varchar
    id:
        id:
            type: integer
            generator: { strategy: AUTO }
    fields:
        value: 
            type: string
            length: 255
    manyToOne:
        button:
            targetEntity: Button
            inversedBy: attributeValues
            joinColumn:
                name: button_id
                referencedColumnName: id

For some reason when I run php app/console doctrine:generate:entities I get the following error:

[RuntimeException] Namespace "Andrei\StatisticsBundle\Entity\Attribute\Value" does not contain any mapped entities. 

I can't understand why is this happening. Can someone point me to the right direction? Thank you.

zuzuleinen
  • 2,604
  • 5
  • 38
  • 49
  • 1
    Shouldn't the name of the config file be `ButtonVarchar.orm.yml`? – Michal Trojanowski Dec 17 '13 at 10:16
  • That was the problem Michal. Thank you! But for some reason, after renaming I get the following error when running the cli command: Invalid mapping file Invalid mapping file 'Andrei.StatisticsBundle.Entity.ButtonVarchar.orm.yml' for class 'Andrei\StatisticsBund le\Entity\ButtonVarchar'. – zuzuleinen Dec 17 '13 at 12:22
  • check this one: http://stackoverflow.com/questions/16624324/symfony2-jobeet-tutorial-day-3-error-invalid-mapping – Michal Trojanowski Dec 17 '13 at 12:43
  • I figured out. My filename for db mapping should be named Attribute.Value.ButtonVarchar.orm.yml instead of ButtonVarchar.orm.yml – zuzuleinen Dec 17 '13 at 12:47

3 Answers3

1

Did you add your StatisticsBundle to Doctrine config?

eg:

doctrine:
  orm:
    auto_mapping: true
    mappings:
         AndreiStatisticsBundle: ~

You can see mapping problem in the following link:

https://github.com/symfony/symfony/pull/675

Skillberto
  • 113
  • 1
  • 6
  • But it works for al entities located in Andrei/StatisticsBundle/Entity. The problem appears if I use entities from Andrei\StatisticsBundle\Entity\Attribute\Value – zuzuleinen Dec 17 '13 at 12:19
  • In my opinion, you don't use Entity from \Attribute\Value directory, just put it into Andrei\StatisticsBundle\Entity. Doctrine maybe parse only from the Entity root. – Skillberto Dec 17 '13 at 15:46
0

It seems that your entities are separated into fine grained packages. In that case you need to specify fully qualified namespace in order for it to work.

 targetEntity: Fully\Qualified\Namespace\To\Button
Jovan Perovic
  • 19,846
  • 5
  • 44
  • 85
0

It may also help.

This works:

MyUniqBundle:Entity

This doesn't work:

MyUniqBundle/Entity
Oleksii Zymovets
  • 690
  • 8
  • 14