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