In PHPCR (NoSQL) there is something like Uuid (it's something different than Id in the table, unique only for the single table) - the Id that is unique to all Documents (Entities) in the whole data base. It's of much help when e.g. using forms, because I can use Uuid without knowing the exact class of an entity, and still being able to access directly a related record just by:
$objectManager->find(null, $uuid);
I'd like to have a similar solution with the RDBMS in the Doctrine ORM, i.e. to find a record when knowing only its unique id (Uuid). Do anyone of you know about such a solution?
From the PHPCR-ODM documentation:
Each document can have a unique identifier for referencing it. While the uuid is also exposed as a read-only string property, the proper mapping for it is mapping it as UUID.
UPDATE:
Here are the Doctrine's sources:
From the general Doctrine common lib https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Persistence/ObjectManager.php#L42
public function find($className, $id);
From the ORM https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/EntityManager.php#L380
public function find($entityName, $id, $lockMode = null, $lockVersion = null)
But I don't stick to find() method.
The equivalent
$entityManager->find()
method does not allow for the entity parameter to be null. So no, there is no way to do the same using the ORM.I would surmise the reason for this is that document db's are quite different from relational databases. In a relational database you would need to query every table. To put it another way, using an ORM you would need to query every entity. With a document database, as far as I can tell, each document is a set whereas in a relational database sets are derived.
I hope that helps and makes sense. I've no experience with document databases. The method signature for
find()
in the ORM seems to explain it though.