Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MappingException: Class Namespace\Entity is not a valid entity or mapped super class. #13

Open
getme opened this issue May 19, 2012 · 4 comments

Comments

@getme
Copy link

getme commented May 19, 2012

This happens when entity uses ORM alias

like this

<?php
namespace Namespace;

use Doctrine\ORM\Mapping as ORM;

/**
 * Enttity
 * 
 * @ORM\Entity(repositoryClass="Namespace\Entity")
 * @ORM\Table(name="table")
 */
class Entity
{
...
}

is it possible to fix this?

@itavero
Copy link
Contributor

itavero commented May 25, 2012

Have you read the Doctrine2 documentation and/or the Symfony2 book?
The entity class is not the repository class.
I suggest reading this:
http://symfony.com/doc/current/book/doctrine.html#custom-repository-classes

@getme
Copy link
Author

getme commented May 25, 2012

Hi @itavero
I'm not sure I understand you answer, can you explain?

I have fixed it already though

AnnotationRegistry::registerFile($app['db.orm.class_path'].'/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');

            $reader = new FileCacheReader(
                    new AnnotationReader(),
                    $app['em.cache_dir'].'/annotation',
                    $app['debug']
            );
            $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $app['em.entity_dirs']);

@itavero
Copy link
Contributor

itavero commented May 25, 2012

In you're example you're telling Doctrine 2 to use your Entity class as the Repository class for that Entity. Just pointing out that that's probably not what you want.

@getme
Copy link
Author

getme commented May 25, 2012

I see what you mean, that's just an example please ignore, repositoryClass is obviously diffrent ) Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants