Hibernate创建步骤

(五大核心接口:Configuration/SessionFactory/Session/Transaction/Query)

1.新建工程,导入需要的jar包。

2.利用MyEclipse自动生成功能在工程中创建hibernate.cfg.xml配置文件和

 HibernateSessionFactory.java工具类。生成的主要内容如下:

hibernate.cfg.xml:

 1 <hibernate-configuration>
 2 
 3     <session-factory>
 4         <property name="connection.username">root</property>
 5         <property name="connection.url">
 6             jdbc:mysql://localhost:3306/databasename
 7         </property>
 8         <property name="dialect">
 9             org.hibernate.dialect.MySQLDialect
10         </property>
11         <property name="myeclipse.connection.profile">
12             dangdang
13         </property>
14         <property name="connection.password">root</property>
15         <property name="connection.driver_class">
16             com.mysql.jdbc.Driver
17         </property>
18         <mapping resource="entity/User.hbm.xml" />
19 
20     </session-factory>
21 
22 </hibernate-configuration>
View Code

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2021-04-18
  • 2021-12-16
  • 2021-12-10
  • 2021-11-23
  • 2021-08-12
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2021-07-07
  • 2022-03-01
  • 2021-07-07
  • 2022-02-11
  • 2021-11-27
  • 2021-04-12
相关资源
相似解决方案