Hi -
I have been following the generic DAO discussion in this thread. I have implemented a generic DAO in our project and have been using it. The implemnetation is based on pure JDBC, but the user can program using the interfaces and completely transparent about the implementation. Now I am planning to have an alternative implementation using JPA.
My question is more in line with Spring configuration for the generic DAOs - hence I thought of starting a separate thread in this forum.
The base class for the DAO is
Every concrete DAO extends this :Code:public abstract class DAOBase<T extends DomainBase> { ... }
The base class uses the pimpl idiom (aka bridge pattern) to provide the implementation. So the user programs to the interface only (the base abstract class) and is totally transparent to the implementation. My sample Spring configuration XML is as follows :Code:public class EmployeeDAO<T extends DomainBase> extends DAOBase<T> { ... }
These DAOs are being injected into domain objects - hence the <aop:spring-configured> in the xml. Each concrete DAO class also provides a factory method makeDAO for self creation.HTML Code:<aop:spring-configured/> <bean id="empdao" class="org.dg.gen.EmployeeDAO" lazy-init="true" factory-method="makeDAO"> </bean> <bean class="org.dg.gen.Employee" singleton="false"> <property name="dao"><ref bean="empdao"/></property> </bean>
With the above design I will have to have entries for all concrete DAOs and domain objects within the Spring XML. I would like to avoid it. My question is : can I have some Spring trick in place so that I can have some sot of generic configuration in the XML. I would love to avoid putting all concrete DAOs in the XML - please note that all DAOs extend from DAOBase and all domain objects extend from DomainBase. e.g. For Employee domain object, I will have EmployeeDAO<Employee> instantiated. Can I use this inheritance relationship to make my xml contain only the generic definitions, based on which the beans can be instantiated.
Any help will be appreciated.
Cheers.
- Debasish


Reply With Quote