Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-51

"No identifier/primary key specified for Entity" problem, Doctrine Beta 3 cannot find primary key

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-BETA4
    • Fix Version/s: 2.0.0-RC1-RC3
    • Component/s: Schema Managers
    • Labels:
      None
    • Environment:
      windows xp, sql server 2008, php 5.3

      Description

      when execute

      php doctrine.php orm:convert-mapping --from-database annotation "Entities"

      get error message

      No identifier/primary key specified for Entity 'Classname(Tablename)'. Every Entity must have an identifier/primary key.

      For resolving this problem
      I've replaced the line

      public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
      {
      ...
      $indexes = $this->tables[$tableName]->getIndexes();
      ...
      }

      in function "loadMetadataForClass" in \\Doctrine\ORM\Mapping\Driver\DatabaseDriver.php by

      public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
      {
      ...
      $indexes = $this->_sm->listTableIndexes($tableName);
      ...
      }

      then the beta 3 works for my date base

      It is because doctrine look for $indexes['prime'] to construit the primary key in entities. when we use "$this->tables[$tableName]>getIndexes()", the keys in $indexes are the real name of indexes of the data base, and in my database, the primary key indexes are named PK_TABLENAME. So I have to use $this>_sm->listTableIndexes($tableName) to pre-edit the indexes before get the list

        Activity

        Minxuan GUO created issue -
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Assignee Roman S. Borschel [ romanb ] Benjamin Eberlei [ beberlei ]
        Roman S. Borschel made changes -
        Fix Version/s 2.0-RC1 [ 10091 ]
        Hide
        Benjamin Eberlei added a comment -

        This is an error in the MSSQL SchemaManager, it is not correctly setting the primary = true key in the index retrieve method. I move that issue to DBAL and reassign to juokaz

        Show
        Benjamin Eberlei added a comment - This is an error in the MSSQL SchemaManager, it is not correctly setting the primary = true key in the index retrieve method. I move that issue to DBAL and reassign to juokaz
        Benjamin Eberlei made changes -
        Project Doctrine 2 - ORM [ 10032 ] Doctrine DBAL [ 10040 ]
        Key DDC-780 DBAL-51
        Affects Version/s 2.0.0-BETA4 [ 10071 ]
        Affects Version/s 2.0-BETA3 [ 10060 ]
        Component/s Schema Managers [ 10057 ]
        Component/s ORM [ 10012 ]
        Fix Version/s 2.0.0-RC1 [ 10094 ]
        Fix Version/s 2.0.0 [ 10067 ]
        Fix Version/s 2.0-RC1 [ 10091 ]
        Benjamin Eberlei made changes -
        Assignee Benjamin Eberlei [ beberlei ] Juozas Kaziukenas [ juokaz ]
        Benjamin Eberlei made changes -
        Fix Version/s 2.0.0 [ 10067 ]
        Fix Version/s 2.0.0-RC1 [ 10094 ]
        Hide
        Juozas Kaziukenas added a comment -
        Show
        Juozas Kaziukenas added a comment - I believe this is now fixed, but I'll test more https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php#L118
        Hide
        Benjamin Eberlei added a comment -

        Fixed.

        Show
        Benjamin Eberlei added a comment - Fixed.
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0-RC1 [ 10094 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 11854 ] jira-feedback2 [ 17660 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17660 ] jira-feedback3 [ 20015 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-51, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Juozas Kaziukenas
            Reporter:
            Minxuan GUO
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: