Hii friends before going to know the details about hibernate, first of all we have to know what is JDBC and what are the disadvantages of JDBC...then we will know hibernate and why hibernate.
What is JDBC ?
JDBC(Java Database Connectivity) is a technology or we can say it is a simple java program when it execute, it will manage the relational database, that means it provides a set of Java API for accessing the relational databases from Java program. JDBC provides a flexible architecture to develop different database applications that can execute on different platforms.
In this tutorial i have given a depth concepts of Hibernate framework by taking varieties of examples. It was developed by Gavin King and had started in 2001. Now I am presenting disadvantages of JDBC and how hibernate is eliminating the disadvantages of JDBC.
Hibernate is an ORM tool which make easy of java application to communicate with database. It simplifies the data creation, data manipulation and data access. It is a programming phenomenon which maps the object to the data stored in the database. Hibernate is a non-invasive framework, means it can not forces the programmers to extend/implement any class/interface, and it is lightweight due to POJO classes. Hibernate can run with in or without server. Hibernate is purely for persistence (to store/retrieve data from Database).
There are 4 layers in hibernate architecture java application layer, hibernate framework layer, backhand api layer and database layer. The Hibernate architecture includes many objects persistent object, session factory, transaction factory, connection factory, session, transaction etc. Following is a very high level view of the Hibernate Application Architecture.
Hibernate uses many objects like session factory, session, transaction etc. And existing Java API such as JDBC (Java Database Connectivity), JTA (Java Transaction API) and JNDI (Java Naming Directory Interface) internally.
A Session is an interface which is used to establish a connection with a database physically. The Session object is lightweight and designed to be instantiated each time an interaction is needed with the database. Persistent objects are saved and retrieved through a Session object. The session objects should not be kept open for a long time because they are not usually thread safe and they should be created and destroyed them as needed. The main function of the Session is to offer create, read and delete operations for instances of mapped entity classes. Instances may have one of the following form at a given point in time: