Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between DAO and Spring Beans?

I'm starting to program in Java (with the Spring Framework) and finding myself confused about the difference between DAOs and Spring's Beans. Do they serve to the same purpose?

like image 759
anderson Avatar asked Nov 10 '10 01:11

anderson


People also ask

Is Spring repository a DAO?

Spring Repository is very close to DAO pattern where DAO classes are responsible for providing CRUD operations on database tables. However, if you are using Spring Data for managing database operations, then you should use Spring Data Repository interface.

What is the difference between DAO and repository in Spring boot?

DAO is an abstraction of data persistence. However, a repository is an abstraction of a collection of objects. DAO is a lower-level concept, closer to the storage systems. However, Repository is a higher-level concept, closer to the Domain objects.

What is Spring DAO?

Spring DAO(Data Access Object): is an object that provides an abstract interface to JDBC implementation frameworks i.e. Spring DAO is generalized concept to access JDBC and Hibernate, MyBatis, JPA, JDO using it's individual Support classes.

What is difference between DAO and service?

Service is the utility that defines the business logic of the application. DAO or Data Access Object is used to interact with the database directly.


1 Answers

DAO == Data Access Object. It's one way to write a persistence layer.

Spring can manage DAO beans and lots of other kinds, like message-driven beans, services, web controllers, and anything else you can encapsulate into a bean.

Spring has three parts:

  1. Inversion of Control (IOC). Think of Spring as a big factory for creating and managing beans.
  2. Aspect-oriented programming (AOP). This is how Spring manages cross cutting concerns like logging, transactions, proxying, remoting, and other activities that otherwise would be littered throughout your application.
  3. Framework code, like the persistence templates for JDBC, Hibernate, TopLink, etc.; remoting; web MVC; etc. They write better code than we do - you get to just use it.
like image 102
duffymo Avatar answered Oct 05 '22 23:10

duffymo