In this example I am going to show you how we can implement Many to One(@ManyToOne) relationship using JPA persistence API in Java.
The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database.
The JPA is used to reduce the burden of writing codes for relational object management, a programmer or developer follows the ‘JPA Provider’ framework, which allows easy interaction with database instance. The JPA being a Java framework a programmer also needs not to worry about the SQL part of the code, he/she may need to hardly concentrate on SQL coding.
In this Many to One mapping example, we have Teacher and Period relationship. Many teachers can be assigned to a class period or in the other words, a class period can be taken by multiple teachers at different times.