<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/project?useUnicode=true&characterEncoding=utf8
</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">yao13539753785</property>
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="current_session_context_class">thread</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="Department.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
- connection.url:表示数据URL
- connection.driver_class:表示数据库驱动
- connection.username:表示数据库用户
- connection.password:表示数据库用户密码
- dialect:用于配置Hibernate使用的数据库类型。Hibernate支持所有的主流数据库,包括Oracle,DB2,SQL Server,和MySQL等。
- current_session_context_class指定currenetSession()方法得到的Session由谁跟踪管理。thread指定Session由当前执行的线程跟踪管理
- show_sql:如果设置为true,程序运行时会在控制台上输出SQL语句
- format_sql:如果设置为true,程序运行时会在控制台上输出格式化后的SQL语句
- hbm2ddl.auto:生成表的策略
- mapping:映射对象模式文件