Spring Hibernate DAO Implementation with interface
Intro
Assuming we have a module called Account Management in our project called foo,
We might can make use of the following package structure.
- foo.service.AccountManagement
- foo.service.AccountManagementImpl
- foo.dao.AccountDAO
- foo.dao.hibernate.AccountDAOImpl (In this case hibernate)
- foo.model.Account
Spring Wiring
<bean id="accountDAO" class="rb.dao.hibernate.AccountDAOImpl"></bean>
<bean id="accountManagement" class="foo.service.AccountManagementImpl">
<property name="accountDAO">
<ref bean="accountDAO"/>
</property>
</bean>
So note that you can replace the accountDAO with some other implementation class, probably using pure JDBC or ibatis.
Summary
As the experts say, always code to interfaces to cater for different implementations.
