Java Reference
In-Depth Information
Listing 5-16. PolicyDetailDaoImpl.java
public class PolicyDetailDaoImpl extends HibernateDaoSupport
implements PolicyDetailDao{
public List listPolicyByProductCode(String productCode) {
return getHibernateTemplate().find( "from ProductDetail where
productCode = ?", productCode);
}
//other methods
}
The getHibernateTempate method of HibernateDaoSupport supplies a HibernateTemplate
object. This is similar to the JdbcTemplate class. It also implements the GOF Template
Method design pattern and carries out the workflow associated with the Hibernate ORM
to interact with the RDBMS. It is important to note here that, even if you have changed
the underlying ORM persistence implementation, the business tier code will be unaf-
fected. This is because the business tier objects access the DAOs using interfaces. Thus,
you have seen the value of P2I.
Consequences
Benefits
• The high-level Spring JDBC API makes it easy to access relational databases.
• Spring JDBC implements the boilerplate low-level code, resource management,
and exception handling. The result is a significant reduction in code and hence
development effort.
• The use of named parameter support makes application code more robust.
• Spring-based DAOs provide a consistent interface to the business tier for data
access.
Concerns
• There is a significant learning curve to start off, even though the API is concise.
 
Search WWH ::




Custom Search