2. Let’s Know First What is JDBC & ORM is …
The Java Database Connectivity is a free open-source
application programming interface. It is a API which
specifies interfaces for connectivity between the java
applications and a wide range of databases.
It is the traditional process to
interact with the database.
ORM is responsible to store Object Model data
into Relational Model and further read the data from
Relational Model into Object Model.
3. Saving data using JDBC
We write code manually to store objects(data) to database using jdbc.
4. ORM
SAVING DATA USING ORM(Hibernate)
-> Now It is done by Mapping of object with the column field.
-> It is done by Hibernate internally. For that we have to map our data members to table’s field.
-> Mapping is done by 2 ways to mapped our objects to save in hibernate –
a) Using xml b) Annotation
-> We don’t have to write queries for the operations(create, read, update, delete).
-> Maps data directly from class to database fields.
6. Why ORM over JDBC :-
In ORM, we only have to create object of class and map it.
No need write lengthy code. It is time efficient.
It simplifies the process to deal with the database.
It boosts the application Development . ORM
(Hibernate) is light weight
ORM fills gap in the mismatches between Object model and
relational model.
NOTE – It is not faster than JDBC, and also In its backend JDBC
is internally running and saving data into DB using queries.