Eagle1
Eagle1

Reputation: 810

Doctrine does not map its own generated entity

I'm trying to learn Doctrine.

I'm trying to update my database with the last generated entity.

I generated the entity with doctrine:generate:entity

here it is:

<?php

namespace NRtworks\ChartOfAccountsBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Lasttest
 *
 * @ORM\Table()
 * @ORM\Entity
 */

class Lasttest
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=255)
 */
private $name;


/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set name
 *
 * @param string $name
 * @return Lasttest
 */
public function setName($name)
{
    $this->name = $name;

    return $this;
}

/**
 * Get name
 *
 * @return string 
 */
public function getName()
{
    return $this->name;
}
}


?>

So basic stuff, I did not change anything.

Then I'd like doctrine to generate the table in my sql database but here is the answer to:

doctrine:mapping:info -> you do not have any mapped entity

doctrine:schema:update -> you do not have metadata class to process

doctrine:generate:entities RandomnameBundle -> does not contain any mapped entities

Any hint ?

Upvotes: 2

Views: 2032

Answers (3)

Eagle1
Eagle1

Reputation: 810

I did not exactly found the problem but it's solved

-> I have updated Symfony to its last version

Upvotes: 0

ishenkoyv
ishenkoyv

Reputation: 673

http://docs.doctrine-project.org/en/2.0.x/reference/annotations-reference.html#annref-table

@ORM\Table requires table name.

Required attributes:

name: Name of the table

Upvotes: 0

Turdaliev Nursultan
Turdaliev Nursultan

Reputation: 2576

Try changing doctrine orm mapping from auto_mapping to manual. Example shown below:

doctrine:
    ...
    orm:
       ...
       auto_mapping: true

TO

orm:
    entity_managers:
        default:
            mappings:
                NRtworks\ChartOfAccountsBundle: ~

Upvotes: 2

Related Questions