@RestController annotation in Spring MVC

We usually use the @Controller annotation to develop Spring MVC applications, but since version 4.x, Spring has introduced another annotation called @RestController. What is the purpose of annotation @RestController? What is the difference between @Controller annotation and @RestController annotation? In this tutorial, let’s find out!… 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

JPA and Spring framework

In JPA, the EntityManagerFactory object is an entity management object that manages the connection to the database. Using Spring to manage this object will help us a lot in developing Java applications that use JPA. In this tutorial, I will guide you on how to… Read More