Before understanding Hibernate, let’s understand about ORM.
What is ORM ?
ORM stands for Object Relational Mapping
In any Java application, we will have objects which are representing the data that we store in the Database.
To store the data in the database, we need tables to be created in the DB and these tables are also called relational entities.
If we want to store these objects into database tables directly without writing any SQL, we need to map the class with the tables so that each object of that class can be mapped to each row in that table.
This kind of mapping between object and tables is called Object Relational Mapping(ORM).
So in ORM
class in java is referred to table in DB.
Instance of class also called objects referred to rows in the database table.
Each attribute in the class refers to each column in the table.
What is Hibernate?
Hibernate internally uses JDBC API to interact with the database
Hibernate is an open source and lightweight ORM and persistence framework which allows us to map plain old java objects to relational database tables.
It facilitates the storage and retrieval of java domain objects via Object Relational Mapping.
Hibernate is created by Gavin King
Hibernate is a lightweight or non-invasive framework because it does not force the programmers to extend any classes or to implement any interfaces.
Need for Hibernate?
Hibernate has come up with many benefits over JDBC which insists us to use it.
Let’s see those benefits in the below conversation between Teacher and a Student