To further clarify my initial problem, I rewrote the question with more 'DDD'-termini, common patterns and discussion arguments. The orginal version can be found under revisions.
Where and how are identities for entities/aggregate roots being generated inside the domain when correctly applying DDD?
I need to assign unique identities to my entities, either upon creation or persisting. Those identities can come in several styles
There are many approaches for the task of generation and assignment of identities, from using factories to create identities, delegation to the infrastructure using ORM or database generation etc. However, if correctly applying DDD, where and how should identities be generated, considering that we don't want anemic domain models and injection of services into entities?
I would place it in a factory. Generating id shouldn't be a part of domain logic in my opinion, because it's really an infrastructure matter. You can take id from DB or generate it with uuid or whatever. It's a detail. Also remember that only interface of a factory belongs to domain layer, not its implementation.
About your doubts for factory, if you use factory to create entities then you should use it everywhere. This is how I do it.