原文:sessionFactory.getCurrentSession()的引出

当业务逻辑中需要开启事务执行,业务逻辑也要调用底层操作数据库的函数,那函数也要开启事务操作。 如果用sessionFactory.openSession 的话会引起处理不在同一个事务中,会造成出错。所以必须保证它们的事务都是相同的 sessionFactory.getCurrentSession 需要在Hibernate.cfg.xml中配置 lt 用于配置当前线程用的 gt lt propert ...

2014-06-09 14:03 0 3762 推荐指数:

查看详情

Hibernate openSession() 和 getCurrentSession的区别 .

Hibernate openSession() 和 getCurrentSession的区别 getHiberanteTemplate 、getCurrentSession和OpenSession 采用getCurrentSession()创建的Session会绑定到当前的线程中去、而采用 ...

Fri Feb 10 03:10:00 CST 2012 0 9557
hibernate sessionFactory

hibernate中的SessionFactory,Session,configuration Session接口   Session接口对于Hibernate 开发人员来说是一个最重要的接口。然而在Hibernate中,实例化的Session是一个轻量级的类,创建 ...

Mon Mar 26 19:21:00 CST 2012 0 5626
openSession 与 getCurrentSession的区别

1、openSession 每一次获得的是一个全新的session对象,而getCurrentSession获得的是与当前线程绑定的session对象 package cn.kiwifly.view; import org.hibernate.SessionFactory; import ...

Sun Dec 07 18:05:00 CST 2014 1 2590
spring配置hibernate的sessionFactory

之前用spring2+hibernate3+struts2开发了一个彩信发布系统,由于第一次使用此架构,造成applicationContext.xml中的配置非常冗长,而且经常因为更改一个小配置项( ...

Thu May 08 07:02:00 CST 2014 0 3719
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM