zoukankan      html  css  js  c++  java
  • hibernate学习笔记(3)hibernate常用配置以及session对象

    更改hibernate.cfg.xml的内容,常用配置有:

    <!--  把hibernate运行时的SQL语句显示到控制台  -->

    <property name="show_sql">true</property>

    <!--  输出到控制台的SQL语句是否排版  -->

    <property name="format_sql">true</property>

    <!--  生成具体的表结构,create是每次重新生成表结构,若已存在,则先将原有的表删除再创建,update是每次更新,保留原有的测试数据  -->

    <property name="hbm2ddl.auto">create</property>

    <!--  生成表结构的时候自动加上前缀  -->

    <property name="hibernate.default_schema">hibernate</property>

    <!-- 使用getCurrentSession打开会话 -->

    <property name="hibernate.current_session_context_class">thread</property>

    session对象:hibernate操作数据库通过session对象来实现,表示数据库的连接

    一般用openSession来开启session对象,getCurrentSession需要在配置文件中配置

  • 相关阅读:
    Nginx proxy开启cache缓存
    Nginx Server 配置
    nginx 全局配置
    Nginx 配置文件解析
    Python-Scrapy框架
    Python-shutil模块
    os模块3
    os模块
    python os模块atime ,ctime,mtime意义
    Python-正则表达式
  • 原文地址:https://www.cnblogs.com/lzhc/p/6515180.html
Copyright © 2011-2022 走看看