On Mon, 17 Jan 2011 16:16:34 -0800 (PST), Philipp Schächtele
<philipp.schaecht...@googlemail.com> wrote:
> Hey Symfony Users,
> 
> when trying to persist a Document with MongoDB in the current version
> of the Symfony2 Sandbox I receive the following Exception:
> 
> "No identifier/primary key specified for Document 'Application
> \TestBundle\Document\Test'. Every Document must have an identifier/
> primary key."
> 
> My document file looks quite easy. I also tried various variation of
> syntax (eg. with @mongodb), various index definitions (in the class
> annotations, setting the id as index) - none worked. I kept on
> receiving the same Exception.
> 
> <?php
> 
> namespace Application\TestBundle\Document;
> 
> /**
>  * @Document(collection="test")
>  */
> class Test
> {
>     /** @Id */
>     protected $id;
> 
>     /** @String @Index */
>     protected $title;
> 
>     /** getters and setters **/
> }
> 
> 
> Any Idea what my problem could be?
> 
> Thanks for helping in advance.
> 
> Cheers, Philipp

The mongoDB annotations have to be namespaced with @mongodb: in the
Symfony2 project as stated in the Symfony2 doc:
http://docs.symfony-reloaded.org/master/guides/doctrine/mongodb-odm/index.html
This is the difference with the Doctrine doc as the namespace is added by
DoctrineMongoDBBundle to avoid conflicts with the validation annotations
(same occurs for the ORM with the @orm: namespace)
So it will be @mongodb:Document() @mongodb:Id()...

Regards

-- 
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