I try to implement solution for Generic DAO like this https://stackoverflow.com/a/511417. However for “Using this genericDAO without special implementation Class” case I get the NoSuchBeanDefinitionException.
The full stacktrace http://pastebin.com/HwrjEZiX
As I see Spring can't wiring bean for Generic Dao without special implementation class
https://dl.dropboxusercontent.com/u/8384811/Misc/2013-05-14_224944.jpg Spring uses the JdkDynamicAopProxy for wiring BranchHibernateDao class, “Using this genericDAO with special implementation Class” case.
According JavaDoc it Creates a dynamic proxy, implementing the interfaces exposed by * the AopProxy. Dynamic proxies cannot be used to proxy methods defined in classes, rather than interfaces.
So it sees the methods from BrunchDao and Crud interfaces for branchDao bean definition.
However it can't wire the branchGenericDao (“Using this genericDAO without special implementation Class” case) and don't see the Crud interface methods.
I'll appreciate for any help!
Bean's wiring
<bean id="branchDao" class="org.jtalks.poulpe.model.dao.hibernate.BranchHibernateDao" parent="genericDao"/>
<bean id="branchGenericDao" class="org.jtalks.common.model.dao.hibernate.GenericDao">
<qualifier value="branchGenericDao"/>
<constructor-arg name="sessionFactory" ref="sessionFactory"/>
<constructor-arg name="type" value="org.jtalks.poulpe.model.entity.PoulpeBranch"/>
</bean>
<bean id="genericDao" abstract="true" class="org.jtalks.common.model.dao.hibernate.GenericDao">
<constructor-arg name="sessionFactory" ref="sessionFactory"/>
</bean>
Test source is here https://github.com/jtalks-org/poulpe/blob/master.senleft/poulpe-model/src/test/java/org/jtalks/poulpe/model/dao/hibernate/BranchHibernateDaoTest.java
Crud source is here https://github.com/jtalks-org/jtalks-common/blob/master.senleft/jtalks-common-model/src/main/java/org/jtalks/common/model/dao/Crud.java
GenericDao source is here https://github.com/jtalks-org/jtalks-common/blob/master.senleft/jtalks-common-model/src/main/java/org/jtalks/common/model/dao/hibernate/GenericDao.java
BranchHibernateDao source is here https://github.com/jtalks-org/poulpe/blob/master.senleft/poulpe-model/src/main/java/org/jtalks/poulpe/model/dao/hibernate/BranchHibernateDao.java