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

DBAL-51: "No identifier/primary key specified for Entity" problem, Doctrine Beta 3 cannot find primary key #1714

Closed
doctrinebot opened this issue Aug 31, 2010 · 5 comments
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user minxuan.guo:

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
{quote}
public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
...
{color:red}$indexes = $this->tables[$tableName]->getIndexes();{color}
...
}
{quote}
in function "loadMetadataForClass" in \Doctrine\ORM\Mapping\Driver\DatabaseDriver.php by
{quote}
public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
...
{color:red}$indexes = $this->_sm->listTableIndexes($tableName);{color}
...
}
{quote}
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

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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

@doctrinebot
Copy link
Author

Comment created by juokaz:

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

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed.

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.0.0-RC1-RC3 milestone Dec 6, 2015
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant