doctrine错误:schema:验证Payum令牌

时间:2014-07-21 20:08:27

标签: symfony payum

我按照此处的文档设置Payum:http://payum.org/doc/0.10/PayumBundle/get_it_started

我在这里使用此实体作为我的安全令牌:

namespace Acme\PaymentBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Token;

/**
 * @ORM\Table(name="payum_security_token")
 * @ORM\Entity
 */
class PayumSecurityToken extends Token
{
}

当我尝试设置我的数据库时,我收到此错误:

$ php app/console doctrine:schema:update --force
[Doctrine\ORM\Mapping\MappingException]                                                          
  No identifier/primary key specified for Entity "Acme\PaymentBundle\Entity\PayumSecurityToken" sub class of "Payum\Core\Model\Token". Every Entity must have an identifier/primary key.      

doctrine:schema:update [--complete] [--dump-sql] [--force] [--em [=" ..."]]

namespace Acme\DemoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Token;

/**
 * @ORM\Table(name="payum_security_token")
 * @ORM\Entity
 */
class PayumSecurityToken extends Token
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
}

它创建一个只有一列的表:id

我做错了什么或我该怎么做才能解决这个问题?

我的composer.json:

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.5.*",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": "~1.2",
    "twig/extensions": "~1.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~3.0",
    "sensio/framework-extra-bundle": "~3.0",
    "incenteev/composer-parameter-handler": "~2.0",
    "friendsofsymfony/user-bundle": "~1.3",
    "gedmo/doctrine-extensions": "~2.3",
    "sonata-project/admin-bundle": "~2.2",
    "sonata-project/doctrine-orm-admin-bundle": "~2.2",
    "payum/payum-bundle": "*@stable",
    "payum/paypal-pro-checkout-nvp": "*@stable"
},

由于

1 个答案:

答案 0 :(得分:2)

您是否在config.yml文件中设置了映射? (我最后添加了自动映射)。

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    entity_managers:
        default:
            mappings:
                payum:
                    is_bundle: false
                    type: xml
                    dir: %kernel.root_dir%/../vendor/payum/core/Payum/Core/Bridge/Doctrine/Resources/mapping

                    # set this dir instead if you use `payum/payum` library
                    #dir: %kernel.root_dir%/../vendor/payum/payum/src/Payum/Core/Bridge/Doctrine/Resources/mapping

                    prefix: Payum\Core\Model
            auto_mapping: true