ZF-Commons / ZfcUserDoctrineORM

Doctrine2 ORM storage adapter for ZfcUser.
BSD 3-Clause "New" or "Revised" License
89 stars 92 forks source link

No identifier/primary key specified for Entity "ZfcUserDoctrineORM\Entity\User" sub class of "ZfcUser\Entity\User". Every Entity must have an identifier/primary key. #22

Closed ghost closed 12 years ago

ghost commented 12 years ago

Hi Evan, When accessing /user by login or register :

No identifier/primary key specified for Entity "ZfcUserDoctrineORM\Entity\User" sub class of "ZfcUser\Entity\User". Every Entity must have an identifier/primary key.

David

EvanDotPro commented 12 years ago

Hmm, I'm not sure why you'd get this... best I can tell, there is a primary key.

ghost commented 12 years ago

Interesting. Not sure what the issue is directly. Maybe @Ocramius can help?

ghost commented 12 years ago

Maybe this issue is relative to pk name "user_id". Each of my pk are named "id" to avoid problems ;-)

Ocramius commented 12 years ago

You can call the PK as you wish. Did you change something in the entities/mappings? What are the operations you are executing? Do you have a stack trace?

ghost commented 12 years ago

The problem appears when i copy module.config.php (https://github.com/ZF-Commons/ZfcUserDoctrineORM/blob/master/config/module.config.php) into my autoload directory and rename this file to zfcuserdoctrineorm.global.php without changing anything. If i don't copy this file, everything works fine.

File:

N:\DEV\APPLICATIONS\rencontres\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\MappingException.php:38

Message:

No identifier/primary key specified for Entity "ZfcUserDoctrineORM\Entity\User" sub class of "ZfcUser\Entity\User". Every Entity must have an identifier/primary key.

Stack trace:

#0 vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php(887): Doctrine\ORM\Mapping\MappingException::identifierRequired('ZfcUserDoctrine...')
#1 vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php(187): Doctrine\ORM\Mapping\ClassMetadataInfo->validateIdentifier()
#2 vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php(170): Doctrine\ORM\Mapping\ClassMetadataFactory->validateRuntimeMetadata(Object(Doctrine\ORM\Mapping\ClassMetadata), NULL)
#3 vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(302): Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata(Object(Doctrine\ORM\Mapping\ClassMetadata), NULL, false, Array)
#4 vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(205): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata('ZfcUserDoctrine...')
#5 vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(268): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('ZfcUserDoctrine...')
#6 vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php(621): Doctrine\ORM\EntityManager->getClassMetadata('ZfcUserDoctrine...')
#7 vendor\zf-commons\zfc-user-doctrine-orm\src\ZfcUserDoctrineORM\Mapper\User.php(30): Doctrine\ORM\EntityManager->getRepository('ZfcUserDoctrine...')
#8 vendor\zf-commons\zfc-user\src\ZfcUser\Validator\AbstractRecord.php(104): ZfcUserDoctrineORM\Mapper\User->findByEmail('true5@true5.com')
#9 vendor\zf-commons\zfc-user\src\ZfcUser\Validator\NoRecordExists.php(12): ZfcUser\Validator\AbstractRecord->query('true5@true5.com')
#10 vendor\zendframework\zendframework\library\Zend\Validator\ValidatorChain.php(187): ZfcUser\Validator\NoRecordExists->isValid('true5@true5.com', Array)
#11 vendor\zendframework\zendframework\library\Zend\InputFilter\Input.php(151): Zend\Validator\ValidatorChain->isValid('true5@true5.com', Array)
#12 vendor\zendframework\zendframework\library\Zend\InputFilter\BaseInputFilter.php(182): Zend\InputFilter\Input->isValid(Array)
#13 vendor\zendframework\zendframework\library\Zend\Form\Form.php(377): Zend\InputFilter\BaseInputFilter->isValid()
#14 vendor\zf-commons\zfc-user\src\ZfcUser\Service\User.php(63): Zend\Form\Form->isValid()
#15 vendor\zf-commons\zfc-user\src\ZfcUser\Controller\UserController.php(157): ZfcUser\Service\User->register(Array)
#16 vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(150): ZfcUser\Controller\UserController->registerAction()
#17 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent))
#18 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#19 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#20 vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#21 vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(151): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#22 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#23 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#24 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#25 vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(317): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
Ocramius commented 12 years ago

Well, looks like metadata for the parent class isn't loaded correctly...

masterpuppet commented 12 years ago

Hi,

I have the same problem but for different reasons, in the case of @booradleys he is overriding the paths key with the wrong directory, but in my case is due to changes in DoctrineModule\Service\DriverFactory(https://github.com/doctrine/DoctrineModule/commit/2991130e5cb7e027600eafbf3954080de5e22950#L13L86), the extension is not checked anymore and the default value in the configuration of the module is null, for now I have added the extension key to my configuration

'zfcuser_entity' => array(              
    'extension' => '.dcm.xml'
)

sorry about my english guys

regards,

Pablo

Ocramius commented 12 years ago

@masterpuppet my bad, guess I should put a default value or throw an exception in the DriverOptions. Please let me know on DoctrineModule

mludewig commented 12 years ago

Hey @all, after install actual version (today) via composer i get the Primary-Key Error during usage of zfc-user-doctrine-orm

No identifier/primary key specified for Entity 'ZfcUserDoctrineORM\Entity\User'. Every Entity must have an identifier/primary key.

During usage of last version (Beta5 from last week) i could overwrite installd zf-common elements with actual downloadable version and it works. But this is not a solution :) . So my favourite way is to use only composer, but i get the "primary key error". Hope anyone can help me. Thanks a lot

mludewig

drdev commented 12 years ago

Same error here with clear install. Both cli and http backends

mludewig commented 12 years ago

Hey hoochie, solved the problem with adding the "minimum-stability": "dev", statement in composer.json. but i think its only a solution for the moment.

drdev commented 12 years ago

yeah, I found exact this solution independently. But anyway, thank you.