原文:openSession 與 getCurrentSession的區別

openSession 每一次獲得的是一個全新的session對象,而getCurrentSession獲得的是與當前線程綁定的session對象 package cn.kiwifly.view import org.hibernate.SessionFactory import org.hibernate.cfg.Configuration import org.hibernate.class ...

2014-12-07 10:05 1 2590 推薦指數:

查看詳情

Hibernate openSession() 和 getCurrentSession區別 .

Hibernate openSession() 和 getCurrentSession區別 getHiberanteTemplate 、getCurrentSessionOpenSession 采用getCurrentSession()創建的Session會綁定到當前的線程中去、而采用 ...

Fri Feb 10 03:10:00 CST 2012 0 9557
sessionFactory.getCurrentSession()的引出

當業務邏輯中需要開啟事務執行,業務邏輯也要調用底層操作數據庫的函數,那函數也要開啟事務操作。 如果用sessionFactory.openSession()的話會引起處理不在同一個事務中,會造成出錯。所以必須保證它們的事務都是相同 ...

Mon Jun 09 22:03:00 CST 2014 0 3762
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM