hibernate.cfg.xml的配置详解

来源:互联网 发布:中国式父母 知乎 编辑:程序博客网 时间:2024/05/21 04:23

<?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.url">jdbc:mysql://localhost:3306/purchase</property><property name="connection.username">purchase</property><property name="connection.password">purchaseLiu</property><property name="connection.driver_class">com.mysql.jdbc.Driver</property><!-- 自动提交,若不设置可能可以显示 sql语句,但数据库中没有数据,需要手动提交 --><property name="connection.autocommit">true</property><!-- 方言配置 --><property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property><!-- 打印 sql --><property name="show_sql">true</property><property name="format_sql">true</property><!--验证模式,否则会报 validator找不到的错误--><property name="javax.persistence.validation.mode">none</property><!--若为 update,当前映射表与数据库中数据表不符,更新--><!--若为 create,无论有无都会重建一个数据库--><property name="hbm2ddl.auto">update</property><!-- 加载配置文件 --><mapping resource="com/purchase/tarena/entity/User.hbm.xml" /></session-factory></hibernate-configuration>


暂时使用这些,会继续更新,若有错请指正,在下不胜感激。

原创粉丝点击