How to get Doctrine2 entity identifier without knowing its name
问题 I am attempting to create an abstracted getId method on my base Entity class in Symfony2 using Doctrine2 for a database where primary keys are named inconsistently across tables. When inspecting entity objects I see there is a private '_identifier' property that contains the information I am trying to retrieve but I am not sure how to properly access it. I'm assuming there is some simple Doctrine magic similar to: public function getId() { return $this->getIdentifier(); } But I haven't