Introduction to Hibernate


Hibernate is an open source Object Relational Mapping (ORM) tool. It allows us to persist Plain Old Java Objects (POJO) to the database. The POJO refers to normal Java objects that do not do any special function nor implement any special interfaces of any of the Java frameworks such as EJB, JDBC, DAO, JDO, etc. Although hibernate internally uses JDBC API to interact with the database, it simplifies the development of Java application to interact with the database. The following are some of the advantages of using hibernate:

  • It is an open source framework under the LGPL licence and hence may be freely downloaded.
  • Hibernate allows us to use database independent queries written in Hibernate Query Language (HQL). So, changing the underlying database is simply a matter of modifying very few lines of code.
  • Hibernate internally uses several levels of caching. Hence, the performance of hibernate framework is unquestionable.
  • This framework also provides the facilities to create database tables automatically. So, programmers need not know SQL syntax.
  • It also supports caching queries and provides statistics about query and database status.


We assume that the latest version of Java is already installed on your computer. Download .zip (for windows) or .tgz (for Unix) from We downloaded the file and when unzipped, a set of files was generated. A sample screen shot is shown in Figure 23.1:

The lib directory contains a set of folders containing Hibernate library. The primary JAR files to use hibernate API are stored in lib/required folder. Modify your classpath environment variable to point these JAR files or specify them using -cp option of Java and javac command. If you are using an IDE such as Eclipse, place them in your project library directory.


A typical hibernate application is developed using the following steps:

  • Writing a POGO class
  • Creating a database table
  • Creating configuration and mapping files
  • Write code to save, retrieve, update, delete objects

Source: Uttam Kumar Roy (2015), Advanced Java programming, Oxford University Press.

Leave a Reply

Your email address will not be published. Required fields are marked *