Hibernate.cfg.xml相关的参数配置

来源:互联网 发布:http aq.js cj.com 编辑:程序博客网 时间:2024/05/22 06:09
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<hibernate-configuration>
<session-factory>
     <!--设置此属性表示应用程序可以自动生成表:update表示应用程序启动时会与数据库的表进行匹配,如果匹配不了就会报错  -->
     <property name="hbm2ddl.auto">update</property>   


<!-- 设定此应用程序使用了什么类型的数据库 -->
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<!-- 在程序运行时是否显示sql语句 -->
<property name="show_sql">true</property>
<!-- 加载驱动 -->
<property name="connection.driver_class">
com.microsoft.sqlserver.jdbc.SQLServerDriver
</property>
<!-- 设置数据库url -->
<property name="connection.url">
jdbc:sqlserver://127.0.0.1:1433;databaseName=student
</property>
<!-- 设置数据库用户名 -->
<property name="connection.username">pengtian</property>
<!-- 设置数据库密码 -->

<property name="connection.password">123456</property>
<!-- 打开二级缓存 -->
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</property>
<!-- 打开统计信息 -->
<property name="hibernate.generate_statistics">true</property>




<!-- 配置映射文件 -->
<mapping resource="hibernate/domain/Person.hbm.xml" />


</session-factory>
</hibernate-configuration>
原创粉丝点击