SSH整合,第二篇。

 

创建工程

这里只是测试和理解hibernate。建立Java工程就好了。

hibernate包下的required,即\hibernate-release-4.2.21.Final\required。

 SSH整合 第二篇 工程初建

 

 

 

2、hibernate.cfg.xml

 

 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 
 6 <hibernate-configuration>
 7 
 8     <session-factory>
 9 
10         <!-- Database connection settings -->
11         <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
12         <property name="connection.url">jdbc:mysql://localhost:3306/dbfortest</property>
13         <property name="connection.username">root</property>
14         <property name="connection.password">root</property>
15 
16         <!-- JDBC connection pool (use the built-in) -->
17        <!--  <property name="connection.pool_size">1</property> -->
18 
19         <!-- SQL dialect -->
20         <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
21 
22         <!-- Enable Hibernate's automatic session context management -->
23         <property name="current_session_context_class">thread</property>
24 
25         <!-- Disable the second-level cache  -->
26         <!-- <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property> -->
27 
28         <!-- Echo all executed SQL to stdout -->
29         <property name="show_sql">true</property>
30         
31         <!-- format_sql -->
32          <property name="format_sql">true</property>
33 
34         <!-- Drop and re-create the database schema on startup 
35         validate |create|create-drop|update
36         -->
37        <!--  <property name="hbm2ddl.auto">update</property> -->
38         
39         <!-- mapping 注解的是class="....." --->
40         <mapping class="com.xzw.ssh.pojo.User" />
41         <mapping class="com.xzw.ssh.pojo.Permission" />
42         <mapping class="com.xzw.ssh.pojo.UserAndRole" />
43         <mapping class="com.xzw.ssh.pojo.Role" />
44         <mapping class="com.xzw.ssh.pojo.RoleAndPermission" />
45 
46     </session-factory>
47 
48 </hibernate-configuration>
hibernate.cfg.xml

相关文章:

  • 2022-12-23
  • 2022-01-19
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2021-04-09
  • 2022-12-23
  • 2021-08-09
猜你喜欢
  • 2021-05-15
  • 2021-08-14
  • 2021-08-18
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案