当前位置: 移动技术网 > IT编程>网页制作>CSS > hibernate的配置

hibernate的配置

2018年11月01日  | 移动技术网IT编程  | 我要评论

hibernate的配置

1,什么是hibernateorm框架/持久层框架

优势:跨的无缝移植

maven 下载资源网站https://mvnrepository.com/

2. 如何在项目中添加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)

实体映射文件一定要加到核心配置文件

3注意

hibernate3.3.2版本中getsession().connection()已被弃用,hibernate4中官方推荐使用session dowork()方法进行jdbc操作

下面配置一个hibernate 的maven项目

3。1新建一个项目

在这里插入图片描述

 

然后配置核心的hibernate.cfg.xml

 

在这里插入图片描述

 

root 123 jdbc:mysql://localhost:3306/t207useunicode=true&characterencoding=utf-8 com.mysql.jdbc.driver org.hibernate.dialect.mysqldialect

true

true

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网