The best way to map a JPA and Hibernate many-to-many association with extra columns

Introduction For a simple many-to-many database relationship, you can use the @ManyToMany JPA annotation and, therefore, hide the join table. However, sometimes you need more than the two Foreign Key columns in the join table, and, for this purpose, you need to replace the @ManyToMany association with two bidirectional @OneToMany associations. Unlike unidirectional @OneToMany, the bidirectional relationship is the best way to map a one-to-many database relationship that requires a collection of Child elements on the parent side In this article, we are going to see how you can map a many-to-many… Read More