Spring Application(part 3)
Integrating Hibernate with Spring
Learning Spring’s DAO philosophy
DAO stands for data access object, which perfectly desc
ribes a DAO’s role in an application
DAOs exist to provide a means to read and write data to
the database.
They should expose this functionality through an interfa
ce by which the rest of the application will access them.
Figure in next page shows the proper approach to desig
n-ing your data access tier.
Service objects should depend on an interface to access data.
As you can see, the service objects are accessing the
DAOs through interfaces.
This has a couple of advantages. First, it makes your
service objects easily testable since they are not cou
pled to a specific data access implementation.
In fact, you can create mock implementations of thes
e data access interfaces.
That would allow you to test your service object witho
ut ever having to connect to the data-base, which wou
ld significantly speed up your unit tests.
评论0