更改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需要在配置文件中配置

hibernate学习笔记(3)hibernate常用配置以及session对象

 

相关文章:

  • 2022-01-14
  • 2021-12-26
  • 2021-12-26
  • 2022-01-23
猜你喜欢
  • 2021-07-21
  • 2021-08-04
  • 2021-06-06
  • 2021-11-09
  • 2022-01-10
  • 2021-10-04
  • 2022-12-23
相关资源
相似解决方案