-
什么是hibernate
ORM框架/持久层框架
object reference mapping
通过管理对象来改变数据库中的数据
通过管理对象来操作数据库
mybatisnew person()
dao dao
jdbc hibernate
jdbc优势:跨数据库的无缝移植
注1:Object Relational Mapping
-
如何在项目中添加hibernate支持(手动添加)
2.1 添加hibernate相关依赖
2.2 在resource目录下添加hibernate.cfg.xml(核心配置文件)
2.2.1 添加DTD支持
2.2.2 添加Hibernate的配置
2.2.2.1 数据库相关(connection.username|connection.password|connection.url|connection.driver_class|dialect)
2.2.2.2 调试相关(show_sql|format_sql)
2.3 在开发阶段再创建实体类和实体映射文件(*.hbm.xml)
实体必须实现Serializable接口
小结:hibernate.cfg.xml(1)/*.hbm.xml(N)
实体映射文件一定要加到核心配置文件
- hibernate核心API讲解
3.1 Configuration
读取hibernate.cfg.xml
3.2 SessionFactory(1)
3.3 Session(N)
注1:
注2:
3.3.1 save
3.3.2 get(不讲load方法,在hibernate对象状态时再讲)<