Hibernate: About_Hibernate

As Said before, in the home page, Object-Oriented programming and traditional communication with a Database are two different paradigms; and continuous switching between them is tough and time consuming.

Hibernate was a solution to such a challenge; as it handles the communication with the database by transforming the queries and instructions set by the user, in an object oriented approach, to its equivalent SQL queries. This allows developers to work in the whole application with an Object- Oriented paradigm, while delegating the Database conversations to Hibernate.

For example, You want to insert the a new record to the table 'Lecturer'; Hibernate will enable you to do it in a way similar to this:

Lecturer L1 = new Lecturer(); L1.setFirstName ("Fatma"); L1.setLastName("Meawad"); save(L1);

In addition to saving data, it allows you to search and Query the records of the Database.

This is the so called, Object-Relational Mapping (ORM). ORM is defined by pcmag.com as "Converting data from tables in a relational database to objects and vice versa".

There are many ORM tools for Java, .NET, PHP, Python... etc. Some of them are open source, others aren't. Ebean, EclipseLink, and TopLink are considered Java ORM tools. Other tools like LINQ, Nhibernate, and Neo are ORM tools for .NET. Here is list of ORM tools by Wikipedia.

Hibernate is considered the most popular ORM tool for Java. Its commonly recognized features are

  • Development time reduction
  • The ease of switching between different Databases.
Read more about Hibernate Features at RoseIndia and AllAppLabs

Besides Object Relational Mapping, Hibernate has two other components, those are:

  • Connection Management
  • Transaction Management
These components are out of our tutorial's scope, so you can read more about them from RoseIndia .

Now you have an overview on ORM in Hibernate; let's start using it. But before going into a code details, next section is to show you the structure of a Hibernate application, and the functions of the files and classes we will be using in our example.