Doctrine ORM: Exception “Duplicate entry ‘2147483647’”

I was storing Facebook and Twitter profile IDs and I got this error:

  [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147
  483647' for key 'PRIMARY'

  [PDOException]
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147
  483647' for key 'PRIMARY'

When I went back to my data there was no ID with 2147483647 value. Then I realized that 2147483647 is the maximun value you can store in MySQL with a Doctrine integer type. So I just changed integer to bigint in my entities and the problem was solved.

class TwitterProfile
{
    /**
     * @ORM\Id
     * @ORM\Column(type="bigint")
     */
    protected $id;
    ...
}

doctrine-mysql-duplicate-entry-2147483647

You might also like

Install Doctrine2 with PEAR in MacPorts
Run those commands:sudo /opt/local/bin/pear channel-discover pear.doctrine-project.org sudo /opt/local/bin/pear...

SonataAdminBundle: Fix “The “ batch action is not defined” at app/vendor/sonata-project/admin-bundle/Controller/CRUDController.php in a shared hosting: magic_quotes_gpc
I was getting http 500 errors while deleting entities in SonataAdminBundle using the batch mode (selecting...

Multiple class inheritance with Doctrine ODM in Symfony: One collection for multiple document types
When you use Doctrine ORM in Symfony all the data is stored in tables having every row the same columns....

Symfony2 – ErrorException: Notice: serialize() [function.serialize]: “xxx” returned as member variable from __sleep() but does not exist in …
While storing an entity from Doctrine2 in the session under a Symfony2 application I got this error:ErrorException:...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.