在UAP的实际操作中,我们会发现,一般情况下,只有在bizc类中能够获取hibernateDao,通过hibernateDao对数据库的操作。那有时候我们想通过其他的类,非bizc类来获取hibernateDao并对数据库进行操作,该如何实现呢?解答如下:
1、非bizc类中获取 hibernateDao
<bean id="componentFactory" class="com.sgcc.uap.utils.ComponentFactory"></bean>
2)代码调用:
IHibernateDao dd=(IHibernateDao)ComponentFactory.getBean("hibernateDao");//获取hibernateDao
Object bizc=ComponentFactory.getBean("temployeeBizc");//获取某一bizc
System.out.println("====>>>>hibernateDao: "+dd);
System.out.println("====>>>>bizc: "+bizc);
本文介绍如何在非bizc类中通过配置ComponentFactory获取hibernateDao对象,进而实现对数据库的操作。主要步骤包括在配置文件中添加ComponentFactory Bean定义,并通过代码调用获取所需的DAO实例。

4519

被折叠的 条评论
为什么被折叠?



