many-to-many unidirectional association

/, JPA/many-to-many unidirectional association

In a relational database in a many-to-many relationship, a row in table X can have  more than one matching row in table Y, a row in table Y can have more than one matching row in table X.

In Object oriented programming, one instance of entity refers to multiple instances of another entity and an instance of that another entity refers to multiple instances of the other entity in the  relation called many-to-many relation.

In this tutorial used the relationship between Engineering Branch and Subjects that are having each Engineering branch in a semester. In an Engineering college each Branch have many Subjects and each Subject may appear in many Engineering branch semester.

many-to-many Tables structure in Database :

what is join table?

A join table is a table in database that represents the multiple references of one or more table . In other words a join table is used to refer multiple records of one or more tables by using foreign key constraints. Below image illustrates more about many-to-many association.

Subject.java mapping :

Branch.java mapping :

@JoinTable

    • @JoinTable Used in the mapping of associations. It is specified on the owning side of an association.

    • @JoinTable can be used with embeddable types as well.
    • When a join table is used in mapping a relationship with an embeddable class on the owning side of the relationship, the containing entity rather than the embeddable class is considered the owner of the relationship.

To Understand more about @JoinTable mapping in entity associations see :
Key points to understand associations

many-to-many association testing

Console Output :


Download Application – JPA-ManyToMany-UniDirection.zip (14 KB)

7 Comments

  1. 台彩賓果賓果 September 26, 2017 at 2:19 am - Reply

    台彩賓果賓果

    Howdy would you mind stating which blog platform you’re using? I’m planning to start my own blog in the near future but I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because yo…

  2. 賓果賓果app September 26, 2017 at 2:20 am - Reply

    賓果賓果app

    Normally I do not read article on blogs, but I wish to say that this write-up very pressured me to try and do so! Your writing style has been surprised me. Thank you, very great post.

  3. 數字賓果賓果 September 26, 2017 at 2:20 am - Reply

    數字賓果賓果

    This website is mostly a walk-through for the entire info you wished about this and didn know who to ask. Glimpse here, and youl positively uncover it.

  4. 賓果賓果必勝法 September 26, 2017 at 2:20 am - Reply

    賓果賓果必勝法

    This web page is really a walk-by means of for the entire info you needed about this and didn know who to ask. Glimpse here, and also youl undoubtedly uncover it.

  5. 超級賓果賓果 September 26, 2017 at 2:20 am - Reply

    超級賓果賓果

    Keep functioning ,terrific job!

  6. 賓果賓果怎麼玩 September 26, 2017 at 2:21 am - Reply

    賓果賓果怎麼玩

    Hi, Neat post. There is a problem with your website in internet explorer, would test this?IE still is the market leader and a big portion of people will miss your fantastic writing because of this problem.

    • Satish Varma
      Satish Varma September 29, 2017 at 3:45 pm - Reply

      hey, Thank you so much for sharing your views and sharing us about this issue, this IE issue we never came across, we will test this site in IE, Thank you!!!.

Leave A Comment