hibernate 幾問(wèn)
、 簡(jiǎn)述你對(duì)IoC(Inversion of Control)的理解,描述一下Spring中實(shí)現(xiàn)DI(Dependency Injection)的幾種方式。2、 Spring的Bean有多種作用域,包括:
singleton、prototype、request、session、global session、application、自定義
3、 簡(jiǎn)單描述Spring Framework與Struts的不同之處,整合Spring與Struts有哪些方法,哪種最好,為什么?
4、 Hibernate中的update()和saveOrUpdate()的區(qū)別
5、
2.除application(詳見(jiàn)Spring Framework 2.0 Reference的3.4節(jié)bean的作用域)
3.Spring是完整的一站式框架,而Struts僅是MVC框架,且著重于MVC中的C。Spring有三種方式整合Struts:使用 Spring 的 ActionSupport 類整合 Struts;使用 Spring 的 DelegatingRequestProcessor 覆蓋 Struts 的 RequestProcessor;將 Struts Action 管理委托給 Spring 框架,動(dòng)作委托最好。(詳見(jiàn)使用Spring 更好地處理Struts 動(dòng)作)
Spring 2.0新增一種方式:AutowiringRequestProcessor。(詳見(jiàn)http://www.javaeye.com/topic/24239)
4.saveOrUpdate()方法可以實(shí)現(xiàn)update()的
如果對(duì)象在該session中已經(jīng)被持久化,不進(jìn)行操作;
對(duì)象的標(biāo)識(shí)符屬性(identifier property)在數(shù)據(jù)庫(kù)中不存在或者是個(gè)暫時(shí)的值,調(diào)用save()方法保存它;
如果session中的另一個(gè)對(duì)象有相同的標(biāo)識(shí)符拋出一個(gè)異常;
以上皆不符合則調(diào)用update()更新之。
5、 在context中定義DataSource,創(chuàng)建SessionFactoy,設(shè)置參數(shù);DAO類繼承HibernateDaoSupport,實(shí)現(xiàn)具體接口,從中獲得HibernateTemplate進(jìn)行具體操作。在使用中如果遇到OpenSessionInView的問(wèn)題,可以添加OpenSessionInViewFilter或OpenSessionInViewInterceptor。(詳見(jiàn)Spring Framework 2.0 Reference的12.2節(jié)Hibernate)
聲明式事務(wù)需聲明事務(wù)管理器,在context中設(shè)置<tx:advice>指定屬性,用<aop:config>確定<aop:advisor>和<aop:pointcut>。
posted on 2008-08-14 22:02 gdufo 閱讀(254) 評(píng)論(0) 編輯 收藏 所屬分類: Hibernate