快速业务通道

Spring坿旗鷹盾裂?伊??Spring駁強Hibernate議糞? - 園殻秘壇利

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-17

Spring坿旗鷹盾裂?伊??Spring駁強Hibernate議糞?

扮寂:2011-03-29 javaeye jiwenke

O/R垢醤竃?岻朔?酒晒阻俯謹鹸墫議佚連隔消晒議蝕窟。Spring哘喘蝕窟宀辛參宥狛 Spring戻工議O/R圭宛厚圭宴議聞喘光嶽隔消晒垢醤?曳泌Hibernate?和中厘断祥 Spring+Hibernate嶄議Spring糞?恂匯倖酒汽議栃裂。

Spring斤Hinberanate議塘崔頁宥狛LocalSessionFactoryBean栖頼撹議?宸頁匯倖垢 皆Bean議糞??壓児窃AbstractSessionFactoryBean嶄?

Java旗鷹

/**    * 宸頁FactoryBean俶勣糞?議俊笥圭隈?岷俊函誼輝念議sessionFactory議 峙    */    public Object getObject() {      return this.sessionFactory;    }

宸倖峙壓afterPropertySet嶄協吶?

Java旗鷹

public void afterPropertiesSet() throws Exception {      //宸倖buildSessionFactory頁宥狛塘崔佚連誼欺SessionFactory議仇圭      SessionFactory rawSf = buildSessionFactory();      //宸戦聞喘阻Proxy圭隈峨秘斤getCurrentSession議盛舜?誼欺才並暦?購 議session      this.sessionFactory = wrapSessionFactoryIfNecessary(rawSf);    }

厘断枠心心SessionFactory頁奕劔幹秀議?宸倖圭隈載海?淫根阻幹秀Hibernate議 SessionFactory議?勝化帶?

Java旗鷹

protected SessionFactory buildSessionFactory() throws Exception {      SessionFactory sf = null;      // Create Configuration instance.      Configuration config = newConfiguration();      //宸戦塘崔方象坿?並暦砿尖匂?LobHander欺Holder嶄?宸倖Holder頁匯倖 ThreadLocal延楚,宸劔宸乂彿坿祥才?殻鰯協阻      if (this.dataSource != null) {        // Make given DataSource available for SessionFactory configuration.        configTimeDataSourceHolder.set(this.dataSource);      }      if (this.jtaTransactionManager != null) {        // Make Spring-provided JTA TransactionManager available.        configTimeTransactionManagerHolder.set (this.jtaTransactionManager);      }      if (this.lobHandler != null) {        // Make given LobHandler available for SessionFactory configuration.        // Do early because because mapping resource might refer to custom types.        configTimeLobHandlerHolder.set(this.lobHandler);      }      //宸戦頁聞喘Hibernate議光倖奉來議塘崔?宸戦聞喘阻Configuration窃栖 渇?宸乂方象      try {        // Set connection release mode "on_close" as default.        // This was the case for Hibernate 3.0; Hibernate 3.1 changed        // it to "auto" (i.e. "after_statement" or "after_transaction").        // However, for Spring''s resource management (in particular for        // HibernateTransactionManager), "on_close" is the better default.        config.setProperty(Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.ON_CLOSE.toString());        if (!isExposeTransactionAwareSessionFactory()) {          // Not exposing a SessionFactory proxy with transaction- aware          // getCurrentSession() method -> set Hibernate 3.1 CurrentSessionContext          // implementation instead, providing the

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号