tket
tket

Reputation: 1

Spring-Dao is different from Spring-mvc?

I am still learning please advice if I am wrong.

I have one question regarding Spring Dao and spring MVC. I know mvc - model, view, controller. We can say DAO as part of that MVC architecture. But, why Spring-DAO is famous on it's own?

And why that Spring-DAO it self useful for bounding with other structures like hibernet and JSF?

Upvotes: 0

Views: 1547

Answers (3)

BATMAN_
BATMAN_

Reputation: 282

Spring DAO vs spring Mvc is totally different technology for use different purpose. You can configure spring DAO inside of spring MVC but it is not part of spring MVC. Spring DAO is just a data persistence technology such as JPA, Hibernate. But Spring DAO more light and more efficient than JPA or hibernate because if you use JPA you need to use JPQL for database operation.if you are used hibernate you need to use HQL . Need extra effort to convert JPQL or HQL to SQL this process take some time so it is in efficient than Spring DAO. You can write pure SQL statement using Spring DAO and directly execute inside of database

Spring MVC is web base application design pattern. Model ,view controller as you mentioned. Spring MVC is not only MVC frame work java supported.Strust 2 also Based on MVC pattern. But the way of implement is deferent.

Upvotes: 0

Stephen C
Stephen C

Reputation: 719336

The Spring Framework documentation explains the purpose of Spring DAO as follows:

The Data Access Object (DAO) support in Spring is aimed at making it easy to work with data access technologies like JDBC, Hibernate, JPA or JDO in a consistent way. This allows one to switch between the aforementioned persistence technologies fairly easily and it also allows one to code without worrying about catching exceptions that are specific to each technology.

This gives a overview of what Spring DAO is about, and deals with the part of your question about the relationship between Spring DAO and Hibernate.

On the other hand, Spring MVC and JSF are (mostly) about implementing web pages and web sites. They are orthogonal to Spring DAO, JDBC, Hibernate, JPA, JDO and so on. That is, they do different things.

We can say DAO as part of that MVC architecture

This is incorrect. Spring DAO can be used with Spring MVC, but it is not part of Spring MVC or the "MVC architecture".

Upvotes: 2

Aravind Yarram
Aravind Yarram

Reputation: 80194

MVC and DAO are two different patterns solving two different problems on two different application layers (ui layer and data access layer).

Why Spring-DAO is famous on it's own?

Consider a batch application which doesn't involve UI but lots of data access. Here spring's DAO support can greatly simplify in coding the data access layer by taking care of boilerplate code, simplifying transaction support etc.

Upvotes: 4

Related Questions