Java Reference
In-Depth Information
"AGE" NUMBER,
constraint "T_POLICY_DETAIL_PK" primary key ("POLICY_ID")
CREATE sequence "T_POLICY_DETAIL_SEQ"
/
The first step to building DAOs with Spring is to declare interfaces for the DAOs. This
follows program to interface (P2I), as described earlier, as an object design best practice.
It lays out a contract with the clients that deal with the concrete implementations only
through these interfaces. As a result, it is easy to swap or modify implementation classes.
Listing 5-3 shows the DAO interface for the policy details.
Listing 5-3. PolicyDetailDao.java
package com.apress.einusre.persistence.dao.api;
public interface PolicyDetailDao {
String SAVE_POLICY_DETAILS_SQL = " insert into T_POLICY_DETAIL
values(T_POLICY_DETAIL_SEQ.nextval,?,?,?)";
public void savePolicyDetails(String productCd, String name, int age);
}
Figure 5-1 shows the Spring JDBC support classes. Spring provides a convenient class
called JdbcDaoSupport to ease the development of JDBC-based DAO classes. This class is
associated with a data source and supplies the JdbcTemplate object for use in the DAO.
Figure 5-1. Class diagram: Spring JDBC support classes
 
Search WWH ::




Custom Search