Basic about JPA

In this tutorial, as the tutorial introducing basic about Hibernate, not lengthy, I will go straight to an example of JPA with the implementation of Hibernate to give you a first look and understand how JPA works. First, I will create a Maven project as… Read More

Using @ManyToMany annotation in JPA

In this tutorial, we will research together on a final annotation in JPA, beside @ManyToOne, @OneToOne, @OneToMany annotation, to express the relationship between any two tables in the database. That is the annotation @ManyToMany! In case, any two tables have many-many relationships, such as a… Read More

Using @OneToMany annotation in JPA

Suppose, you are working on a project where the database has two tables, such as student and clazz, structured like below:

As you can see, the clazz table has columns id and name with the primary key id. Student table has columns id, name… Read More

Using @ManyToOne annotation in JPA

Annotation @ManyToOne in JPA is used to express multiple-to-one relationships between two tables in a database. There are many records in table A related to a record in table B. For example: many different students may have the same class. In this tutorial, we will… Read More