Hibernate Example

In this tutorial, you will see how to persist the Java objects using the Hibernate Object/Relational Mapping (ORM) framework. Hibernate automates ORM and considerably reduces the number of lines of code needed to persist the object in the database. This example demonstrates how to automatically generate code from the object/relational mapping file, thus saving the developers time. This helps the developers focus on the business problem rather than doing repetitive coding work.

Hibernate uses an XML document or the properties file to define the object/relational mapping. The object/relational mapping file contains the mapping between the Java object and the corresponding database table. This example illustrates how to create the ORM using the XML document.

Hibernate Mapping One-to-Many Using Annotations

In this example, you will learn how to map one-to-many relationship using Hibernate Annotations. Consider the following relationship between Student and Phone entity.

According to the relationship, a student can have any number of phone numbers.

Spring MVC Framework Tutorial

Spring MVC helps in building flexible and loosely coupled web applications. The Model-view-controller design pattern helps in seperating the business logic, presentation logic, and navigation logic. Models are responsible for encapsulating the application data. The Views render a response to the user with the help of the model object. Controllers are responsible for receiving the request from the user and calling the back-end services.

The figure below shows the flow of requests in the Spring MVC Framework.