Rationale behind Dependency Injection Container libraries

This is a question that I’m also interested in getting an answer to. If entities are completely decoupled from any storage and database access mechanisms then if we want to use dependency injection then I can’t see how this is going to work:

This code should be rewritten to something like this:

$blog = $blogRepository->find($blogId);
$author = $blog->getAuthor($userRepository);

Otherwise the entity object is not able to load Author on its own. And even if we inject UserRepository like this and the blog entity can use it to fetch the author then we are beginning to violate SRP because now the entity is dealing with retrieving data. This starts to resemble Active Record.

The problem can be avoided if BlogRepository eager-loads the author (e.g. with a JOIN) but if we prefer lazy loading then I can’t see a way out other than add the responsibility for fetching more data into the blog entity.