SessionFactory

1 用来产生和管理sesssion

2 通常情况下,每个应用只需要一个SessionFactory,除非要访问多个数据库的情况

3 openSession()与openSession()

(1) openSession()总是创建新的session,需要手动close().

(2)getCurrentSession()事务提交则自动关闭.从上下文环境中获得session,如果当时环境中不存就创建新的.如果环境中存在就使用环境中的,而且每次得到的都是同一个session(在session提交之前,提交之后就是新的了).用途:界定事务边界.

所谓的上下文参见配置文件

<property name="current_session_context_classs">thread</property>

取值范围 jta | thread | managed | custom.Class

SessionFactory的openSession与getCurrentSession区别的更多相关文章

  1. hibernate3.6-联合主键注解以及openSession和getCurrentSession区别

    [联合主键]>>>>配置方式:xml:    1. Student中单独创建StudentPk主键实体类 2. 配置: <composite-id name=" ...

  2. hibernate中openSession()跟getCurrentSession()方法之间的区别

    Hibernate openSession() 和 getCurrentSession的区别 getHiberanteTemplate .getCurrentSession和OpenSession 采 ...

  3. Hibernate中openSession() 与 getCurrentSession()的区别

    1 getCurrentSession创建的session会和绑定到当前线程,而openSession每次创建新的session. 2 getCurrentSession创建的线程会在事务回滚或事物提 ...

  4. Hibernate之openSession与getCurrentSession的区别

    openSession 与 getCurrentSession的区别(1)openSession 每一次获得的是一个全新的session对象,而getCurrentSession获得的是与当前线程绑定 ...

  5. sessionFactory中的openSession和getCurrentSession的一些注意事项

    今天进行Hibernate测试时遇到了一个问题 我在用sessionFactory生产seesion时出现了故障,使用getCurrentsesstion时产生异常: Exception in thr ...

  6. openSession()与getCurrentSession()的区别

    getCurrentSession创建的session会和绑定到当前线程,而openSession不会. getCurrentSession创建的线程会在事务回滚或事物提交后自动关闭,而openSes ...

  7. openSession和getCurrentSession的比较

    在比较openSession和getCurrentSession这两个方法之前,我们先认识一下这两个方法. 在进行配置信息管理时,我们一般进行一下简单步骤: Configuration cfg = n ...

  8. Hibernate关于openSession和getCurrentSession的理解

    来源(转载):http://blog.csdn.net/woshisap/article/details/7024482 1:getCurrentSession会把Session和当前的线程关联起来, ...

  9. openSession() 与 getCurrentSession() 有何不同和关联呢?

    在 SessionFactory 启动的时候, Hibernate 会根据配置创建相应的 CurrentSessionContext ,在getCurrentSession() 被调用的时候,实际被执 ...

随机推荐

  1. ASP.NET Session详解(转)

    ASP.NET Session详解 本文章来自:http://blog.163.com/adam601@126/blog/static/22506317200932824210996/ 当用户在 We ...

  2. python的变量 以及操作系统

    变量 : (变量真没有什么好说的) 变: 就是会变化的 量:衡量现实的事物标准 python 中引用 变量值的作用 操作系统:就计算机控制硬件的软件,定义各个硬件的接口给应用软件调用 应用软件:在操作 ...

  3. 使用Themleaf 模板引擎手动生成html文件

    1.为什么要写这一篇呢? 在做一个邮件发送功能的时候,需要发送html邮件,javaMail 发送html 的时候需要有已经生成的html正文,所以需要提前将要发送的内容生成,所以就需要模板引擎来动态 ...

  4. [转帖]JVM总结--JVM体系结构

    JVM总结--JVM体系结构 https://blog.csdn.net/samjustin1/article/details/52215274 需要不断的学习才可以. 2016年08月15日 22: ...

  5. 【转贴】优秀的龙芯Docker虚拟机解决方案

    优秀的龙芯Docker虚拟机解决方案 http://www.loongson.cn/m/view.php?aid=836 时间:2019-05-23 15:03  来源:未知   作者:龙芯中科    ...

  6. 【案例分享】SpreadJS金融行业应用实践,开发基于Web Excel的指标补录平台

    SpreadJS作为一款基于 HTML5 的纯前端电子表格控件,以“高速低耗.高度类似Excel.可无限扩展”为产品特色,提供移动跨平台和浏览器支持,可同时满足 .NET.Java.App 等应用程序 ...

  7. 安装破解MyEclipse2017CI

    一.下载 1.Myeclipse官网下载地址:http://www.myeclipsecn.com/download/ 2.破解补丁链接:https://pan.baidu.com/s/1Ge_fbm ...

  8. Docker部署前后端项目

    本地(ubuntu19.04)安装docker: sudo apt install docker.io SSH连接服务器: 安装Docker: yum update yum -y install do ...

  9. C++多线程基础学习笔记(六)

    condition_variable.wait.notifiy_one.notify_all的使用方式 condition_variable:条件变量 wait:等待被唤醒 notify_one:随机 ...

  10. 安装gitlab ce

    切换到root用户,安装相关依赖 yum install curl policycoreutils openssh-server openssh-clients service sshd restar ...