Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Hibernate use JDBC?

I know that Hibernate uses JDBC behind the scenes, but how does it do this/ where does it do this?

like image 734
rrazd Avatar asked Aug 17 '11 15:08

rrazd


People also ask

Why Hibernate when we have JDBC?

JDBC enables developers to create queries and update data to a relational database using the Structured Query Language (SQL). Hibernate uses HQL (Hibernate Query Language) which is similar to SQL but understands object-oriented concepts like inheritance, association etc.

What is JDBC in Hibernate?

JDBC is acronym of Java database connectivity. It is used to connect your application to the database and transactions . It is an open source Java api. Hibernate is also used for connect your application to database and to do database related transactions but with different approach.

How Hibernate is better than JDBC?

Both Hibernate & JDBC facilitate accessing relational tables with Java code. Hibernate is a more efficient & object-oriented approach for accessing a database. However, it is a bit slower performance-wise in comparison to JDBC. Depending on the requirement of your project, you can choose the most suitable option.


1 Answers

Hibernate uses JDBC to connect to the database and execute the dynamic SQL that it generates.

Hibernate is nothing more than a SQL generation engine - it uses your objects and mappings to generate SQL for you instead of making you write it by hand.

Once it does that, everything is the same as if you had written the SQL yourself.

like image 73
duffymo Avatar answered Sep 19 '22 11:09

duffymo