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

ID field missing from entity PaymentToken #789

Closed
ThomasLandauer opened this issue Dec 18, 2018 · 9 comments
Closed

ID field missing from entity PaymentToken #789

ThomasLandauer opened this issue Dec 18, 2018 · 9 comments

Comments

@ThomasLandauer
Copy link
Contributor

When following https://github.com/ThomasLandauer/Payum/blob/patch-3/docs/symfony/get-it-started.md I cannot create the entities in the database: When I try to set up a migration (bin/console make:migration), I'm getting this error:

In MappingException.php line 46:
No identifier/primary key specified for Entity "App\Entity\PaymentToken" sub class of "Payum\Core\Model\Token". Every Entity must have an identifier/primary key.

I tried to fix this by adding this to the PaymentToken entity (see 7cdcb50 ):

    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    protected $id;

... but this leads to:

An exception occurred while executing 'SELECT t0.id AS id_1 FROM payment_token t0 WHERE t0.id = ?' with params ["iEJnV_zOSUt-aJle301Nn0_x-JtmP4cVqp_vd9BemUE"]:

When looking into https://github.com/Payum/Payum/blob/master/src/Payum/Core/Model/Token.php I can't see any mapping information. So where are the columns for the database table defined??

@makasim
Copy link
Member

makasim commented Dec 18, 2018

The id is up to a user and therefore should not be defined in a basic entity. One might one to use autoincrement where others sequences and other guys UUIDs generated in the client

@makasim
Copy link
Member

makasim commented Dec 18, 2018

Remove the autogenerated strategy. the id is generated by the app and should be unique

https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/PayumBundle/Resources/config/doctrine/model/PaymentSecurityToken.orm.xml#L21

@makasim
Copy link
Member

makasim commented Dec 18, 2018

this should work:

/**
     * @ORM\Id()
     * @ORM\Column(type="string")
     */
    protected $id;

@makasim
Copy link
Member

makasim commented Dec 18, 2018

The "get-it-started" doc misses that part.

@ThomasLandauer
Copy link
Contributor Author

No luck, this leads to:

Entity of type App\Entity\PaymentToken is missing an assigned ID for field 'id'. The identifier generation strategy for this entity requires the ID field to be populated before EntityManager#persist() is called. If you want automatically generated identifiers instead you need to adjust the metadata mapping accordingly.

My table has just this one field (id). There's not even a column for the token! This just can't be right...

@makasim
Copy link
Member

makasim commented Dec 18, 2018

@ThomasLandauer
Copy link
Contributor Author

Adding this didn't change anything :-( Again: Where are the column definitions for this entity? Which columns is it supposed to have?

@ThomasLandauer
Copy link
Contributor Author

@makasim Please help!

@virtualize
Copy link

virtualize commented May 28, 2019

I had to update the doctrine mapping config to get rid of this error message

In MappingException.php line 46:
No identifier/primary key specified for Entity "App\Entity\PaymentToken" sub class of "Payum\Core\Model\Token". Every Entity must have an identifier/primary key.

orm:
    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'

source: https://stackoverflow.com/questions/24873780/error-with-doctrineschemavalidate-for-payum-token

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

3 participants