上一页 1 ··· 51 52 53 54 55 56 57 58 59 ··· 61 下一页
  2018年1月4日
摘要: 1 本章目的:获得session的两种方式: openSession 和 getCurrentSession 2 两种session的使用方法 1openSession可以直接写,getCurrentSession需要在cfg.xml中配置 2 getCurrentSession创建的线程会在事务回 阅读全文
posted @ 2018-01-04 21:58 菜鸟乙 阅读(130) 评论(0) 推荐(0)
  2018年1月3日
摘要: 1 hibernate是非自动提交。如果transaction不写的话,会只创建表结构而不插入语句。 如果不写transaction而想实现插入的功能的话,需要重写session的dowork方法(记得flush)。 2 demo: package hibernate_001; import jav 阅读全文
posted @ 2018-01-03 07:46 菜鸟乙 阅读(157) 评论(0) 推荐(0)
  2018年1月2日
摘要: hibernate流程: 1 配置对象Configurateion 读取 hibernate.cfg.xml 2 会话工厂SessionFactory 读取 user.hbm.xml(创建销毁相当耗费资源,一个数据库只创建一个) 3 会话Session 相当于 jdbc的connect 4 添加事务 阅读全文
posted @ 2018-01-02 22:01 菜鸟乙 阅读(144) 评论(0) 推荐(0)
摘要: 1 hibernate.cfg.xml常用配置: show_sql 控制台打印sql format_sql 控制台将sql排版 hbm2ddl.auto: create 删除表结构,重新建表并插值 update 保存原数据,插入新的数据 dialect: 数据库方言,不同数据库有不同方言 2 hib 阅读全文
posted @ 2018-01-02 21:48 菜鸟乙 阅读(172) 评论(0) 推荐(0)
摘要: 本章简介,主要讲5大块的内容 1 hibernate.cfg.xml的配置 2 session 的简介 3 transaction的简介 4 session的详解 5 对象关系映射常用配置 阅读全文
posted @ 2018-01-02 21:19 菜鸟乙 阅读(125) 评论(0) 推荐(0)
  2017年12月26日
摘要: hibernate 业务流程 1 创建配置对象 Configuration config = new Configuration().configure(); 2 创建服务注册对象 ServiceRegistry serviceRegistry = new ServiceRegistryBuilde 阅读全文
posted @ 2017-12-26 15:40 菜鸟乙 阅读(138) 评论(0) 推荐(0)
摘要: 三大注解: 1 @Test 2 @Before 3 @After 执行顺序213 demo.java package hibernate_001; import org.junit.After; import org.junit.Before; import org.junit.Test; publ 阅读全文
posted @ 2017-12-26 15:11 菜鸟乙 阅读(131) 评论(0) 推荐(0)
  2017年12月20日
摘要: 创建关系映射文件:(把实体类映射成一个表) 1 右键src==>new==>other==>hibernate==>hbm.xml==>Student==>Finish 2 创建mysql数据库 <?xml version="1.0"?><!DOCTYPE hibernate-mapping PUB 阅读全文
posted @ 2017-12-20 00:51 菜鸟乙 阅读(126) 评论(0) 推荐(0)
  2017年12月19日
摘要: java beans 的设计原则 1 公有的类 2 共有不带参数构造方法 3 私有属性 4 属性setter/getter方法 Studnet类: package com.ddwei.student; import java.util.Date; public class Student { // 阅读全文
posted @ 2017-12-19 18:47 菜鸟乙 阅读(99) 评论(0) 推荐(0)
摘要: hibernate 配置文件新建 1 右键src==>new==》other==>hibernate configuration File==>next==>next==>finish 2 填写配置文件:dialect mysql 方言 ; hbm2ddl.auto ddl生成策略 ; 文件模板如下 阅读全文
posted @ 2017-12-19 17:23 菜鸟乙 阅读(133) 评论(0) 推荐(0)
上一页 1 ··· 51 52 53 54 55 56 57 58 59 ··· 61 下一页