hibernate主配置文件的配置

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE hibernate-configuration PUBLIC
 3     "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
 4     "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
 5 <hibernate-configuration>
 6     <session-factory>
 7     
 8         <!-- 
 9         #hibernate.dialect org.hibernate.dialect.MySQLDialect
10         #hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
11         #hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
12         #hibernate.connection.driver_class com.mysql.jdbc.Driver
13         #hibernate.connection.url jdbc:mysql:///test
14         #hibernate.connection.username gavin
15         #hibernate.connection.password
16          -->
17          <!-- 数据库驱动 -->
18         <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
19          <!-- 数据库url -->
20         <property name="hibernate.connection.url">jdbc:mysql:///hibernate_32</property>
21          <!-- 数据库连接用户名 -->
22         <property name="hibernate.connection.username">root</property>
23          <!-- 数据库连接密码 -->
24         <property name="hibernate.connection.password">1234</property>
25         <!-- 数据库方言
26             不同的数据库中,sql语法略有区别. 指定方言可以让hibernate框架在生成sql语句时.针对数据库的方言生成.
27             sql99标准: DDL 定义语言  库表的增删改查
28                       DCL 控制语言  事务 权限
29                       DML 操纵语言  增删改查
30             注意: MYSQL在选择方言时,请选择最短的方言.
31          -->
32         <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
33         
34         
35         <!-- #hibernate.show_sql true 
36              #hibernate.format_sql true
37         -->
38         <!-- 将hibernate生成的sql语句打印到控制台 -->
39         <property name="hibernate.show_sql">true</property>
40         <!-- 将hibernate生成的sql语句格式化(语法缩进) -->
41         <property name="hibernate.format_sql">true</property>
42         <!-- 
43         ## auto schema export  自动导出表结构. 自动建表
44         #hibernate.hbm2ddl.auto create        自动建表.每次框架运行都会创建新的表.以前表将会被覆盖,表数据会丢失.(开发环境中测试使用)
45         #hibernate.hbm2ddl.auto create-drop 自动建表.每次框架运行结束都会将所有表删除.(开发环境中测试使用)
46         #hibernate.hbm2ddl.auto update(推荐使用) 自动生成表.如果已经存在不会再生成.如果表有变动.自动更新表(不会删除任何数据).
47         #hibernate.hbm2ddl.auto validate    校验.不自动生成表.每次启动会校验数据库中表是否正确.校验失败.
48          -->
49         <property name="hibernate.hbm2ddl.auto">update</property>
50         <!-- 引入orm元数据
51             路径书写: 填写src下的路径
52          -->
53          <!-- 指定hibernate操作数据库时的隔离级别 
54             #hibernate.connection.isolation 1|2|4|8        
55             0001    1    读未提交
56             0010    2    读已提交
57             0100    4    可重复读
58             1000    8    串行化
59          -->
60          <property name="hibernate.connection.isolation">4</property>
61          <!-- 指定session与当前线程绑定 -->
62          <property name="hibernate.current_session_context_class">thread</property>
63          
64         <mapping resource="cn/itcast/domain/Customer.hbm.xml" />
65         <mapping resource="cn/itcast/domain/LinkMan.hbm.xml" />
66         <mapping resource="cn/itcast/domain/Role.hbm.xml" />
67         <mapping resource="cn/itcast/domain/User.hbm.xml" />
68         
69     </session-factory>
70 </hibernate-configuration>
原文地址:https://www.cnblogs.com/houchen/p/10639397.html