1。框架是什么
框架是用来提高开发效率的,封装了好多的功能我们使用这些功能的时候,调用即可,不需要手动实现,所以框架就是一个半成品的项目,只要懂得如何使用这些功能即可
我们需要学习的框架和各部分之间的作用
2.
3.使用hibernate的好处
操作数据库的时候我们可以使用面向对象的方式来完成,不需要书写sql语句
hibernate是一款orm框架,orm————指的是object ralationmapping 对象关系映射
二,环境的搭建
1.导包>>>> /hiberante/lib/required 下的所有包+数据库的驱动包
2.创建数据库 准备表和实体()
3.书写主配置文件命名规则是 hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<!-- #hibernate.dialect org.hibernate.dialect.MySQLDialect #hibernate.dialect
org.hibernate.dialect.MySQLInnoDBDialect #hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
#hibernate.connection.driver_class com.mysql.jdbc.Driver #hibernate.connection.url
jdbc:mysql:///test #hibernate.connection.username gavin #hibernate.connection.password -->
<!-- 数据库驱动 -->
<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<!-- 数据库url -->
<property name="hibernate.connection.url">jdbc:mysql:///test1?serverTimezone=UTC</property>
<!-- 数据库连接用户名 -->
<property name="hibernate.connection.username">root</property>
<!-- 数据库连接密码 -->
<property name="hibernate.connection.password">123456</property>
<!-- 数据库方言 不同的数据库中,sql语法略有区别. 指定方言可以让hibernate框架在生成sql语句时.针对数据库的方言生成. sql99标准:
DDL 定义语言 库表的增删改查 DCL 控制语言 事务 权限 DML 操纵语言 增删改查 注意: MYSQL在选择方言时,请选择最短的方言. -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!-- #hibernate.show_sql true #hibernate.format_sql true -->
<!-- 将hibernate生成的sql语句打印到控制台 --&g