Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between DAO and hibernate

Tags:

java

My tutor told me there is difference between DAO and hibernate...i Have been searching for the answer since yesterday, but couldn't find it. Can anyone explain it clearly please.

like image 764
user1217249 Avatar asked Mar 07 '26 01:03

user1217249


2 Answers

DAO (Data Access Object) is a design pattern which defines a way to hide the persistence layer of your application. The classes using its interface will be unaware of the persistence operations and, uncoupled from the database or any other persistece mechanisms you use.

Hibernate is a ORM (object-relational mapping) library, which enable you to map your Java classes to relational tables. Using Hibernate, you can save and query your data from tables without writing SQL queries by hand.

So even if you use Hibernate, you still may want to implement DAO pattern to decouple the persistence layer from your application.

like image 162
Chico Sokol Avatar answered Mar 08 '26 16:03

Chico Sokol


its like the difference between the concept of transport and a diesel engine

DAO is a pattern where you isolate persistence related operations from the rest of your application. its a way to design a data handling component

Hibernate is a specific implementation of an ORM framework. its a tool used to make your DAO implementation simpler (most of the times :P)

like image 40
jambriz Avatar answered Mar 08 '26 16:03

jambriz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!