spring + hibernate + struts 多数据问题,实在搞不通!请指教
spring + hibernate + struts 实现跨数据库,现实现oracle可以,但却换到MYSQL服务类时,怎么都出错,不知道为什么。
如下
取得服务类:(ArticleService) AppContext.getInstance().getAppContext().getBean("articleService");
mysql出错,ORALCE却正常
applicationContext.xml 配置
<bean id="articleService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" >
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="target">
<ref local="articleTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
</bean>
oracle:<bean id="articleTarget" class="com.eweb.business.ArticleService" singleton="true">
<property name="articleDAO">
<ref local="articleDAO" />
</property>
</bean>
MYSQL::<bean id="articleTarget" class="com.eweb.business.ArticleSQLService" singleton="true">
<property name="articleDAO">
<ref local="articleSQLDAO" />
</property>
</bean>
ArticleSQLService即使和ArticleService一样,都报:
java.lang.ClassCastException: com.eweb.business.ArticleSQLService$$EnhancerByCGLIB$$4d6bdd81
com.eweb.util.BaseAction.getArticleService(BaseAction.java:37)
com.eweb.struts.action.ArticleAction.list(ArticleAction.java:101)
实在费解!
类:大致
public class ArticleSQLService implements IArticleService {
private IArticleDAO articleDAO;
public ArticleSQLService() {
super();
}
public IArticleDAO getArticleDAO() {
return articleDAO;
}
public void setArticleDAO(IArticleDAO articleDAO) {
this.articleDAO = articleDAO;
}
public List findByPage(Pager pager, Long catalogId){
int firstResult = (pager.getCurrentPage()-1)*pager.getPageSize();
int maxResults = pager.getPageSize();
return this.getArticleDAO().findByPage(firstResult, maxResults, catalogId);
}
public Long findByPageCount(Long catalogId) {
return this.getArticleDAO().findByPageCount(catalogId);
}
}
搞通宵都不通,实在晕,请各位指教。