1.Hibernate是ORM框架,完成对象的持久化操作。
2.允许开发者采用面向对象的方式来操作数据库。
3.安装Hibernate的插件到Eclipse中来自动生成配置文件。
4.Hibernate环境搭建
5.测试连接数据库
package com.hanqi.test; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; import org.junit.Test; public class Test01 { //测试Hibernate连接数据库 @Test public void test() { //1 获取配置文件 Configuration cfg = new Configuration().configure(); //2 注册配置 ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build(); //3 获取SessionFactory(相当于JDBC的连接) SessionFactory sf=cfg.buildSessionFactory(sr); System.out.println(sf); sf.close(); } }