下面是一个自动生成的配置文件:

<?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"> <!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration> <session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">
zyfMysqlDriver
</property> <mapping resource="com/zyf/hibernate/bean/Person.hbm.xml" />
</session-factory> </hibernate-configuration>

关于数据库连接的部分不再说明,

  <mapping resource="com/zyf/hibernate/bean/Person.hbm.xml" />:加载resource路径下对应的映射文件
  
  <property name="hibernate.hbm2ddl.auto">true</property>
    validate:加载hibernate时验证创建表结构
    update:加载hibernate时自动更新数据库结构,如果表存在不用创建,如果不存在就创建。
    create:每一次加载hibernate时都创建表结构
    create-drop:加载hibernate时创建,退出时删除

  <property name="format_sql">true</property>:把hibernate生成的sql语句格式化

  <property name="show_sql">true</property>:显示hibernate内部生成的sql语句

  

05-11 16:11
查看更多