title: Typeorm many to many relation joinColumns
body: <p>I'm new to typeorm and I'm trying to make this orm work as a charm.
  I have no biggie with simple entities : Photos and albums. I have a joining table to know which picture is inside which album.</p>
  
  <p>So I have the following :</p>
  
  <pre><code>import {
    Entity, PrimaryGeneratedColumn, Column, OneToMany, JoinTable,
  } from 'typeorm';
  import { PicturesModel } from '../pictures/pictures.model';
  
  @Entity({
    name: 'T_ALBUM_AL',
    synchronize: true,
  })
  export class AlbumModel {
    @PrimaryGeneratedColumn({
      name: 'AL_id',
    })
    id: number;
  
    @Column({
      name: 'AL_name',
    })
    name: string;
  
    @Column({
      name: 'AL_created_at',
    })
    created_at: Date;
  
    @Column({
      name: 'AL_updated_at',
    })
    updated_at: Date;
  
    @JoinTable({
      name: 'TJ_PICTURE_ALBUM_PA',
      joinColumn: {
        name: 'PI_id',
        referencedColumnName: 'PI_id',
      },
    })
    @OneToMany(() =&gt; PicturesModel, (pictures: PicturesModel) =&gt; pictures.id)
    pictures: PicturesModel[]
  }
  
  
  import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
  
  @Entity({
    name: 'T_PICTURE_PI',
    synchronize: true,
  })
  export class PicturesModel {
    @PrimaryGeneratedColumn({
      name: 'PI_id',
    })
    id: number;
  
    @Column({
      name: 'PI_name',
    })
    name: string;
  
    @Column({
      name: 'PI_path',
    })
    path: string;
  
    @Column({
      name: 'PI_created_at',
    })
    created_at: Date;
  
    @Column({
      name: 'PI_updated_at',
    })
    updated_at: Date;
  
    @Column({
      name: 'PI_size',
    })
    size: number;
  }
  </code></pre>
  
  <p>So I have a the following model : Note that the User logic is not implemented yet.
  <a href="https://i.stack.imgur.com/19Vu3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/19Vu3.png" alt="enter image description here"></a></p>
  
  <p>I have a very tiny controller to get albums, I would like to retrieve every albums and every pictures inside it :</p>
  
  <pre><code>import { Request, Response } from 'express';
  import { getRepository } from 'typeorm';
  
  import { AlbumModel } from './album.model';
  
  class Album {
    public static async getAlbums(_req: Request, res: Response): Promise&lt;Response&gt; {
      try {
        const picture = await getRepository(AlbumModel).find({ relations: ['pictures'] });
        return res.json(picture);
      } catch (e) {
        console.error(e);
        return res.json('fail');
      }
    }
  }
  
  export default Album;
  </code></pre>
  
  <p>When I call this controller I'm getting the following error : However joinColumns is specified correctly</p>
  
  <pre><code>TypeError: Cannot read property 'joinColumns' of undefined
      at /&lt;something&gt;/src/query-builder/SelectQueryBuilder.ts:1500:61
      at Array.map (&lt;anonymous&gt;)
      at SelectQueryBuilder.createJoinExpression (/&lt;something&gt;/src/query-builder/SelectQueryBuilder.ts:1470:57)
      at SelectQueryBuilder.getQuery (/&lt;something&gt;/src/query-builder/SelectQueryBuilder.ts:54:21)
      at SelectQueryBuilder.QueryBuilder.getQueryAndParameters (/&lt;something&gt;/src/query-builder/QueryBuilder.ts:415:28)
      at SelectQueryBuilder.&lt;anonymous&gt; (/&lt;something&gt;/src/query-builder/SelectQueryBuilder.ts:1956:40)
      at step (/&lt;something&gt;/node_modules/tslib/tslib.js:139:27)
      at Object.next (/&lt;something&gt;/node_modules/tslib/tslib.js:120:57)
      at /&lt;something&gt;/node_modules/tslib/tslib.js:113:75
  </code></pre>
  
  <p>Any ideas ? </p>