That was it! After the Annotation I quoted I had a second @Orm\Table() annotation in the DocBlock specifying indexes. I just wasn't seeing that while trying to solve this problem.
Having now combined the name= and indexes= entries into a single @Orm\Table() annotation, getClassMetadata now reports that the table name is 'user'. Thank you very much for your prompt and insightful reply. On Thursday, February 27, 2014 1:16:32 PM UTC-5, Marco Pivetta wrote: > > It is most likely not picking up your annotation mappings as it seems... > Try modifying them and you will see the outcomes > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > > > On 27 February 2014 19:09, otis <[email protected] <javascript:>>wrote: > >> The class metadata returned by $em->getClassMetadata('Acme\ >> Bundle\UserBundle\Entity\User'); includes the following: >> >> ["table"]=> >>> array(3) { >>> ["name"]=> >>> string(4) "User" >>> ["indexes"]=> >>> string(8) "Array(3)" >>> ["options"]=> >>> string(8) "Array(0)" >>> } >>> >> >> >> >> On Thursday, February 27, 2014 12:59:37 PM UTC-5, Marco Pivetta wrote: >> >>> acme.User? Are you sure that annotation mappings are actually being >>> considered here? What does your metadata for the User entity look like? >>> Check it with: >>> >>> $em->getClassMetadata('Acme\Bundle\UserBundle\Entity\User'); >>> >>> >>> >>> Marco Pivetta >>> >>> http://twitter.com/Ocramius >>> >>> http://ocramius.github.com/ >>> >>> >>> On 27 February 2014 18:32, otis <[email protected]> wrote: >>> >>>> I have an doctrine entity in a Symfony2 project defined as: >>>> >>>> /** >>>> * @ORM\Entity >>>> * @ORM\Table(name="`user`") >>>> */ >>>> class User >>>> >>>> The table name is escaped in this definition, but the problem described >>>> here occurs whether it is escaped or not. >>>> >>>> The associated mysql database does have a table named 'user'. >>>> >>>> Somewhere, somehow, doctrine decides that the table associated with the >>>> entity User is named 'User', not 'user', and goes looking for a table >>>> named >>>> 'User' >>>> >>>> This isn't a problem in my Windows dev environment, but on the linux >>>> production server my app does not work. >>>> >>>> When I do something like this on the linux server: >>>> >>>> $em = $container->get('doctrine')->getManager(); >>>>> $user_repo = $em->getRepository('Acme\Bundle\UserBundle\Entity\User'); >>>>> $user = $user_repo->find(1); >>>>> >>>> >>>> I get this: >>>> >>>> PHP Fatal error: Uncaught exception 'PDOException' with message >>>>> 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'acme.User' >>>>> doesn't exist' in /home/acme/vendor/doctrine/dbal/lib/Doctrine/DBAL/ >>>>> Connection.php:641 >>>>> >>>> >>>> I know it would be better not to use a table named 'user', but I am >>>> working with an existing mysql database in which that is the name of one >>>> of >>>> the tables, and this database is also used by a legacy php app in which >>>> that table name cannot be changed (at least not without enormous >>>> difficulty). >>>> >>>> Can anyone tell me what code causes this and whether it can be fixed, >>>> adjusted, etc? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "doctrine-user" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> >>>> Visit this group at http://groups.google.com/group/doctrine-user. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "doctrine-user" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> Visit this group at http://groups.google.com/group/doctrine-user. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/groups/opt_out.
