What is the difference between DAO and Spring Beans?

I start programming in Java (using the Spring Framework) and find that I am confused by the difference between DAO and Spring Beans. Do they fulfill the same goal?

+4
source share
3 answers

DAO == Data access object. This is one way to record a save layer.

Spring can manage DAO beans and many other types, such as message-driven beans, services, web controllers, and anything else that you can encapsulate in a bean.

Spring has three parts:

  • Inversion of Management (IOC). Think of Spring as a big factory for creating and managing beans.
  • Aspect Oriented Programming (AOP). This is how Spring manages end-to-end issues like logging, transactions, proxying, remote access, and other activities that would otherwise be cluttered throughout the application.
  • Framework code, such as persistence templates for JDBC, Hibernate, TopLink, etc .; Remoting Web MVC etc. They write better code than us, you can just use it.
+4
source

DAOs are designed to abstract how an application creates a data object. More specifically, you can have a UserDAO interface and implement it as UserHibernateDAO , UserIbatisDAO , UserFileDAO and return data to them in the same format from different sources.

Duffimo explained Spring.

+1
source

DAOs are the concept of a template ( http://www.oracle.com/technetwork/java/dataaccessobject-138824.html ).

Spring Beans are class instances managed by Spring.

Of course, you can use Spring IOC to implement the application using DAO.

+1
source

All Articles