Fixes n+1 queries in the EntityRepository