Le 16/05/2011 23:47, Gaku Furukawa a écrit :
Hi there,

I used Symfony2 and Doctrine2.
But I can't use entity's annotation mapping with entity_managers.

could you help me ?


・config.ym.
-----------
doctrine:
   orm:
       default_entity_manager: default
       entity_managers:
           default:
               connection: default
               mappings:
                   MyBundle: { type: annotation, dir: Entity/ }

-------------

・controller
-------------
$em = $this->get("doctrine.orm.entity_manager");
$user = $em->find("User", 1);<----error occured at this
line.
print_r($user);
-------------

In that case, entity classes is not found in the Entity folder.
so I had error when I execute this program.

---
Class User does not exist
500 Internal Server Error - ReflectionException

in C:\data\eclipse_files\eclipse_php\workspace\tank\vendor\doctrine\lib
\Doctrine\ORM\Mapping\ClassMetadata.php
at line 67
---

but when I don't use entity_managers and I use "auto_mapping: true",
this error don't occured.
I want to use entity's annotation mapping with entity_managers.
The issue is simple: as always when using a class name as string, you need to use the fully qualified class name, not the short class name. So it would be /find('Acme\DemoBundle\Entity\User', 1)/ You could also use the alias to reference the entity (which is mapped to the namespace internally by Doctrine): /find('AcmeDemoBundle:User', 1)/

--
Christophe | Stof

--
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to