欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Hibernate openSession 和 getCurrentSession區別

Hibernate openSession 和 getCurrent

發(fā)布日期:11-10-24 05:09    文章來(lái)源:互聯(lián)網(wǎng)

1.采用getCurrentSession()創(chuàng )建的Session會(huì )綁定到當前的線(xiàn)程中去;

而采用OpenSession()則不會(huì )。

2.采用getCurrentSession()創(chuàng )建的Session在commit或rollback后會(huì )自動(dòng)關(guān)閉;

采用OpenSession()必須手動(dòng)session.close()關(guān)閉。

3.采用getCurrentSession()需要在Hibernate.cfg.xml配置文件中加入如下配置:

未綁定當前線(xiàn)程會(huì )出現異常:

org.hibernate.HibernateException:No Hibernate Session bound to thread

*如果使用的是本地事務(wù)(jdbc事務(wù))<propertyname="hibernate.current_session_context_class">thread</property>* 如果使用的是全局事務(wù)(jta事務(wù))

<propertyname="hibernate.current_session_context_class">jta</property>

另外,但是在使用getCurrentSession(),必須在事務(wù)中運行,要不出

org.hibernate.HibernateException:?createQueryis not valid without active transaction

但是,配上事務(wù)后只有將

<propertyname="hibernate.current_session_context_class">thread</property>去掉,程序才能運行這不是前后矛盾么?????難道spring在通過(guò)sessionFactory獲取session時(shí),沒(méi)有調用getCurrentSession()方法。通過(guò)加入事務(wù),提交,所以不需要配置getCurrentSession?

在Hibernate3.2中使用getCurrentSession,只需將其放入一個(gè)事務(wù)中即可!


本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
getCurrentSession()和openSession()的區別
current_session_context_class的意思和管理SESSION
openSession()和getCurrentSession()區別——hibernate
Struts2.3+Spring3.1+hibernate4.0開(kāi)發(fā)中遇到的一些問(wèn)題及其解...
getCurrentSession 與 openSession() 的區別
<property name="current_session_context_class">thread</property> 屬性
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久