title: Nest.js + Mikro-ORM: Collection of entity not initialized when using createQueryBuilder and leftJoin
body: <p>I'm using Nest.js, and considering migrating from TypeORM to Mikro-ORM. I'm using the <a href="https://github.com/dario1985/nestjs-mikro-orm" rel="nofollow noreferrer"><code>nestjs-mikro-orm</code></a> module. But I'm stuck on something that seems very simple...</p>
  
  <p>I've 3 entities, <code>AuthorEntity</code>, <code>BookEntity</code> and <code>BookMetadata</code>. From my <code>Author</code> module, I try to left join the <code>Book</code> and <code>BookMetadata</code> tables with the <code>createQueryBuilder</code> method. But when running my query, I'm getting an error where <code>Collection&lt;BookEntity&gt; of entity AuthorEntity[3390] not initialized</code>. However columns from the <code>Author</code> table are well retrieved.</p>
  
  <p>My 3 entities:</p>
  
  <pre class="lang-js prettyprint-override"><code>@Entity()
  @Unique({ properties: ['key'] })
  export class AuthorEntity {
    @PrimaryKey()
    id!: number;
  
    @Property({ length: 255 })
    key!: string;
  
    @OneToMany('BookEntity', 'author', { orphanRemoval: true })
    books? = new Collection&lt;BookEntity&gt;(this);
  }
  
  @Entity()
  export class BookEntity {
    @PrimaryKey()
    id!: number;
  
    @ManyToOne(() =&gt; AuthorEntity)
    author!: AuthorEntity;
  
    @OneToMany('BookMetadataEntity', 'book', { orphanRemoval: true })
    bookMetadata? = new Collection&lt;BookMetadataEntity&gt;(this);
  }
  
  @Entity()
  @Unique({ properties: ['book', 'localeKey'] })
  export class BookMetadataEntity {
    @PrimaryKey()
    id!: number;
  
    @Property({ length: 5 })
    localeKey!: string;
  
    @ManyToOne(() =&gt; BookEntity)
    book!: BookEntity;
  }
  </code></pre>
  
  <p>And the service file where I run my query:</p>
  
  <pre class="lang-js prettyprint-override"><code>@Injectable()
  export class AuthorService {
    constructor(
      @InjectRepository(AuthorEntity)
      private readonly authorRepository: EntityRepository&lt;AuthorEntity&gt;,
    ) {}
  
    async findOneByKey(props: { key: string; localeKey: string; }): Promise&lt;AuthorEntity&gt; {
      const { key, localeKey } = props;
  
      return this.authorRepository
        .createQueryBuilder('a')
        .select(['a.*', 'b.*', 'c.*'])
        .leftJoin('a.books', 'b')
        .leftJoin('b.bookMetadata', 'c')
        .where('a.key = ?', [key])
        .andWhere('c.localeKey = ?', [localeKey])
        .getSingleResult();
    }
  }
  </code></pre>
  
  <p>Am I missing something? Might be not related, but I also noticed that there is <a href="https://docs.nestjs.com/techniques/database#auto-load-entities" rel="nofollow noreferrer">a special <code>autoLoadEntities: true</code></a> for TypeORM users  using Nest.js. Is there something similar for Mikro-ORM? Thanks ;)</p>