首页 > Web开发 > 详细

hibernate的核心配置

时间:2020-07-03 18:52:20      阅读:48      评论:0      收藏:0      [点我收藏+]
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE hibernate-configuration PUBLIC
 3     "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
 4     "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
 5 <hibernate-configuration>
 6     <session-factory>
 7         <!-- 基础配置-->
 8         <property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
 9         <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/数据库名</property>
10         <property name="hibernate.connection.username">root</property>
11         <property name="hibernate.connection.password">123456</property>
12         
13         <!--     可选配置 -->
14         <!--     打印sql语句 -->
15         <property name="hibernate.show_sql">true</property>
16         <!--     格式化sql -->
17         <property name="hibernate.format_sql">true</property>
18         <!--     自动创建表
19             1.none        :不使用自动建表
20             2.create      :若有表,删除重新创建;若没有,创建表
21             3.create-drop :按create创建表,执行完操作后,删除表
22             4.update      :若有表,则使用;若无表,则创建(课更新表结构)
23             5.validate    :若无表,则不创建新表,仅使用以有表
24              -->
25         <property name="hibernate.hbm2ddl.auto">create</property>
26         <!--     设置数据库隔离级别 -->
27         <property name="hibernate.connection.isolation">4</property>
28         <!--     配置当前线程绑定的session -->
29         <property name="hibernate.current_session_context_class">thread</property>
30         
31         <!-- 添加映射 -->
32         <mapping resource="/hibernate/src/cn/edu/ahtcm/yrxc/text/aaa.hbm.xml"/>
33     </session-factory>
34 </hibernate-configuration>

 

hibernate的核心配置

原文:https://www.cnblogs.com/yrxc/p/13231656.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!