原文: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