- 1 hibernate.cfg.xml常用配置:
show_sql 控制台打印sql
format_sql 控制台将sql排版
hbm2ddl.auto:
create 删除表结构,重新建表并插值
update 保存原数据,插入新的数据
dialect: 数据库方言,不同数据库有不同方言
- 2 hibernate.cfg.xml常用配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/bendi</property>
<property name="connection.username">root</property>
<property name="connection.password">*</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource = "Student.hbm.xml"/>
</session-factory>
</hibernate-configuration>