FIGURE 12-1: Class diagram of the data access pattern
OVERVIEW OF THE DATA ACCESS PATTERN
The implementation of the DAO pattern involves several components:
The DAO interface
The concrete implementation of the DAO interface
The DAO factory
➤ The DTO
The factory, interface, and DTO are optional components, not required components, but you will
see these two patterns used with the DAO pattern. The factory pattern is discussed in further detail
in Chapter 6, “Factory Pattern.”
Data Transfer Object Pattern
The DTO carries the data retrieved from or persisted to the database across logical layers. For
example, to transfer a list of User objects retrieved from the data access layer to the web layer, the
service layer would be responsible for transferring from a DAO to a DTO.
NOTE The DTO is also referred to as the Value Object.
The solution that the DTO pattern proposes is dei ned in Core J2EE Patterns: Best Practices and
Design Strategies as follows:
Use a Transfer Object to carry multiple data elements across a tier.
The DTO reduces remote requests across the network in applications that make many method calls
to enterprise beans, resulting in improved performance. Sometimes not all the data retrieved from
the database is required on the web layer or whatever other layer requires the use of data. So the