itVincent Blog - Java Working Fun!

          技術引領時代!
          posts - 117, comments - 181, trackbacks - 0, articles - 12

          今天一同事要在struts + spring + hibernate下使用jdbc,但發現在HibernateDaoSupport 的getSession.connection()已經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

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

          Feedback

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

          2008-02-01 16:33 by Meimei
          只想坐沙發.

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

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

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

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

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

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

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

          2009-03-08 20:20 by 星火網絡
          試試
          ((SessionImplementor)session).getJDBCContext().borrowConnection();
          請訪問
          <a href='http://www.littlespark.com.cn'>http://www.littlespark.com.cn</a>
          主站蜘蛛池模板: 琼海市| 焉耆| 二连浩特市| 临湘市| 申扎县| 台湾省| 宣恩县| 龙山县| 郓城县| 阿拉善右旗| 丰都县| 安达市| 耒阳市| 成都市| 三原县| 白河县| 肃南| 长春市| 望城县| 蛟河市| 关岭| 汉沽区| 庆阳市| 高阳县| 康平县| 闽侯县| 集安市| 汽车| 仙居县| 柳林县| 六盘水市| 田阳县| 禹城市| 崇礼县| 莱州市| 浪卡子县| 南平市| 吴旗县| 富平县| 天峻县| 开原市|