zoukankan      html  css  js  c++  java
  • Hibernate框架概念

    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();
        }  
    
    }
  • 相关阅读:
    查看mongodb的状态
    superset----缓存之redis
    superset--presto sql
    linux----之tcpdump小用
    Git版本回退的最佳方式
    SpringBoot 热部署
    不使用Tomcat,手写简单的web服务
    Spring Security 入门
    Maven总结
    git高级用法
  • 原文地址:https://www.cnblogs.com/miracle-0807/p/6040467.html
Copyright © 2011-2022 走看看