Nov 10, 2018

JPA many to many mapping example



In Entity A:

    @JoinTable(name = "tableAB", joinColumns = {
        @JoinColumn(name = "A_id", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "B_id", referencedColumnName = "id")})
    @ManyToMany
    private List<B> bs;


In Entity B:

You don't need to have property of entity A in entity B.