What is Data Access Objects (DAOs)?
1. Abstract CRUD (Create, Retrieve, Update, Delete) operations.
Core J2EE Patterns – Data Access Object

2. Allow different implementations to be “plugged in” with minimal impact to the rest of the system
Advanced DAO programming

DAO in context, where does the business logic go?
1. Domain Objects/Business Objects
* Thin Service Layer and Complex OO Domain Model
* Business logic primarily in the Domain/Business Objects

2. Service Layer
* Thin Domain Layer, Procedural Service Layer
* Fowler’s Anemic Domain Model

Service layer and DAO architecture:
1. Service Layer Contains all Business Logic (no real Domain Model)
This type is a Heavy Service Layer that service Layer directly to Data Access Layer[PEAA: Transaction Script].
#1 Data Access Layer returns Data Transfer Objects (DTOs) to Service Layer.[CJP: Transfer Object]
#2 Data Access Layer returns JDBC RowSets to Service Layer.[PEAA: TableModule/Table Data Gateway]

2. Service Layer contains Use Case Logic that operates over thin or moderately complex domain model
#1 Row Data Gateway simple model tightly coupled to database.(ActiveRecord adds business logic)
#2 Entity Beans BMP/CMP
#3 Data Mapper

3. Complex OO Domain Model/Thin Service Layer
implementation by complex O/R Mapping Framework like TopLink, JDO, Hibernate.

4. Approach:
#1. Fully-Functional Service Layer
Generally matches Use Cases; Provides API to Clients

#2. Data Access
* Simple System – DAO returns DTOs
* More complex System
– Object Model utilizing DataMapper or EJB CMP
– Object Model utilizing JDO or Hibernate

#3. Stateless Session Bean as a RemoteFacade
* Delegates calls to Service Layer
* Returns DTOs to caller

Other issues you may consider:
#1. Unit of Work
Keeps track of “dirty” objects in complicated update scenarios. JDO enhancers and Hibernate classes can do this for us automatically
#2. Identity Map
When loading objects from the database, the DAO should store in a Map keyed by Primary Key so duplicate copies are not loaded
#3. Business Transactions may span multiple database transactions
Optimistic Locking
Pessimistic Locking

Architecture view: 

Spring framework

J2EE architecture