itVincent Blog - Java Working Fun!

          技術(shù)引領(lǐng)時代!
          posts - 117, comments - 181, trackbacks - 0, articles - 12

          今天一同事要在struts + spring + hibernate下使用jdbc,但發(fā)現(xiàn)在HibernateDaoSupport 的getSession.connection()已經(jīng)deprecated了,
          public Connection connection() throws HibernateException;上有句說明

          @deprecated
          To be replaced with a SPI for performing work against the connection; scheduled for removal in 4.x

          上去查了一下資料,竟然現(xiàn)在是沒有替代方法的...-0-汗
          雖然使用connection()還是可以的,但是考慮到今后的變化,還是得找個代替方法.
          spring中有個工具類支持了這樣一個功能,并且不是依賴connection()方法的,如下:
          SessionFactoryUtils.getDataSource(getSessionFactory());

          Feedback

          # re: 代替過期的getSession.connection()方法,在hibernate中用jdbc連接數(shù)據(jù)源  回復(fù)  更多評論   

          2008-02-01 16:33 by Meimei
          只想坐沙發(fā).

          # re: 代替過期的getSession.connection()方法,在hibernate中用jdbc連接數(shù)據(jù)源  回復(fù)  更多評論   

          2008-12-02 14:24 by 游客
          我也沒找到.

          # re: 代替過期的getSession.connection()方法,在hibernate中用jdbc連接數(shù)據(jù)源[未登錄]  回復(fù)  更多評論   

          2009-01-08 17:55 by hehe
          ConnectionProviderFactory.newConnectionProvider().getConnection()

          # re: 代替過期的getSession.connection()方法,在hibernate中用jdbc連接數(shù)據(jù)源  回復(fù)  更多評論   

          2009-02-11 15:59 by itVincent
          @hehe
          能取得DataSource,比Connection好,DataSource不用關(guān)注連接釋放的問題

          # re: 代替過期的getSession.connection()方法,在hibernate中用jdbc連接數(shù)據(jù)源  回復(fù)  更多評論   

          2009-03-08 20:20 by 星火網(wǎng)絡(luò)
          試試
          ((SessionImplementor)session).getJDBCContext().borrowConnection();
          請訪問
          <a href='http://www.littlespark.com.cn'>http://www.littlespark.com.cn</a>
          主站蜘蛛池模板: 海淀区| 阿克苏市| 长春市| 呼玛县| 比如县| 昌乐县| 富源县| 前郭尔| 阿克| 姚安县| 比如县| 封丘县| 太康县| 尤溪县| 屏东县| 长顺县| 平阴县| 兴国县| 浙江省| 兴和县| 邻水| 钟祥市| 大港区| 分宜县| 称多县| 慈溪市| 邻水| 英吉沙县| 抚顺市| 綦江县| 石泉县| 建平县| 遂川县| 华安县| 仁寿县| 衡南县| 黄梅县| 平原县| 东明县| 桐庐县| 海淀区|