title: TypeORM: Joining when we have one to many and many to one relationship
body: <pre class="lang-ts prettyprint-override"><code>@Entity()
  export class User {
    @PrimaryColumn()
    id: string;
  
    @Column({unique: true})
    username: string;
  
    @Column({unique: true})
    email: string;
  
    @OneToMany(type =&gt; Post, post =&gt; post.id)
    posts: Post[];
  }
  
  @Entity()
  export class Post {
  
    @PrimaryGeneratedColumn()
    id: number;
  
    @ManyToOne(type =&gt; User, user =&gt; user.posts)
    @JoinColumn({name: 'user_id'})
    user: User;
  
    @OneToMany(type =&gt; Image, image =&gt; image.id)
    images: Image[];
  }
   
  @Entity()
  export class Image {
    @PrimaryGeneratedColumn()
    id: number;
  
    @ManyToOne(type =&gt; Post, post =&gt; post.images)
    @JoinColumn({name : 'post_id'})
    post: Post;
  }
  </code></pre>
  <p>I have these 3 entities and I want to make a query to have all the posts from a user and for that post to get all the images. I am trying to do this using the following code:</p>
  <pre class="lang-ts prettyprint-override"><code>return await this.postRepository.createQueryBuilder(&quot;post&quot;)
    .innerJoinAndSelect(&quot;post.images&quot;, &quot;image&quot;)
    .where(&quot;user_id = :userId&quot;, {userId: id})
    .getMany();
  </code></pre>
  <p>And I get the following error:</p>
  <pre><code>Cannot read property 'joinColumns' of undefined
  </code></pre>
  <p>I also tried this instead of the <code>.innerJoin</code> from above:</p>
  <pre><code>.innerJoinAndSelect(Image, &quot;image&quot;, &quot;image.post_id = post.id&quot;)
  </code></pre>
  <p>This way I don't get that error anymore, but as a result I get only the post and I don't get the images from it</p>