0

i am using the payumBundle for my payment set ups but i keep getting this error:

Duplicate entry '0' for key 'PRIMARY'

These are my classes that i am using

/**
 * @ORM\Table(name="payum_tokenized_details")
 * @ORM\Entity
 */
class TokenizedDetails extends BaseTokenizedDetails
{

    protected $id;

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


}

/**
 * @ORM\Table(name="payum_paypal_express_checkout_payment_details")
 * @ORM\Entity
 */
class PaypalExpressPaymentDetails extends PaymentDetails
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

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


}

i have tried to search but i can't seem to find a solution, normally this is because of the primary keys, but those are all set up correctly

Maxim
  • 3,836
  • 6
  • 42
  • 64
  • The error you see means that the database rejects data because it violates the definition of the data-structure. You most likely did provide the wrong ID somewhere (0). Normally 0 is not a fitting value for a PRIMARY KEY (PK). In your case that value is already inside the database, which shows that you have a more fundamental underlying problem. Not only the duplicate but also that it is already in. Restore your last working backup on another test-system and try to re-create the faulty 0 database entry. – hakre Aug 31 '13 at 08:11
  • Thank you, very good explanation, know i know where i have to look for. – Maxim Aug 31 '13 at 08:18

1 Answers1

0

The TokenizedDetails entity must not have id field because there is token one (which is unique ) and already had been mapped.

See how its defined in sandbox: https://github.com/Payum/PayumBundleSandbox/blob/master/src/Acme/PaymentBundle/Entity/TokenizedDetails.php

And the mapping: https://github.com/Payum/Payum/blob/master/src/Payum/Bridge/Doctrine/Resources/mapping/TokenizedDetails.orm.xml

Pay attention to token field its defined as id.

Maksim Kotlyar
  • 3,821
  • 27
  • 31
  • since 0.6.0 TokenizedDetails was deprecated and removed in 0.7. So now you have to use Token model. previous `token` field was renamed to `hash`. – Maksim Kotlyar Oct 29 '13 at 15:20