hibernate.cfg.xml配置

来源:互联网 发布:泰拉瑞亚骸骨魔弓数据 编辑:程序博客网 时间:2024/05/16 13:54
一、常用配置:


hibernate.cfg.xml

<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhibernate-configurationPUBLIC
           "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- 配置会话属性 -->
<session-factory>
     <!-- 以下属性根据所要连接的数据库进行配置 -->
     <propertyname="myeclipse.connection.profile">com.mysql.jdbc.MySqlDriver</property>
     <propertyname="hibernate.connection.username">root</property>
     <propertyname="hibernate.connection.password">root</property>
     <propertyname="hibernate.connection.url">jdbc:mysql://localhost:3306/spring_demo?useUnicode=true&amp;characterEncoding=utf-8</property>
     <propertyname="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
     <propertyname="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
     <propertyname="hibernate.show_sql">true</property>
     <propertyname="hibernate.hbm2ddl.auto">validate</property>
     <propertyname="dialect">org.hibernate.dialect.MySQLDialect</property>
     <!-- 在下面添加实体关系映射文件 -->
     <mappingresource="com/demo/spring/entity/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
原创粉丝点击