惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Palo Alto Networks Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cyberwarzone
Cyberwarzone
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
Security Latest
Security Latest
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
C
Cisco Blogs
博客园 - 【当耐特】
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
B
Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
The Last Watchdog
The Last Watchdog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
F
Fortinet All Blogs
L
LINUX DO - 热门话题
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
爱范儿
爱范儿
O
OpenAI News
J
Java Code Geeks
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 求知者

更新测试 常用的重试技术—如何优雅的重试 CQRS/ES框架调研 【转】 微服务架构之事件驱动架构 毕业了! 皮鞋美容 重装系统后实战EFS解密 巧用饮食缓解春困 [转]安全防御四步 校园网安全经验谈 2006年猪的述职报告 [转] 某大型IT公司招网络工程师认证试题精选(要求:CCNA或 HCNE以上) win2003负载均衡实现 记录一下 第一次参加招聘会 备考有感 实习一瞥 几十年后我死了 我的QQ号怎么办? 网络工程师学习笔记 中秋贺词集锦
Hibernate Note(Keep update)
求知者 · 2008-11-30 · via 博客园 - 求知者

2008-11-30 Hibernate学习小结:

一、Demo解析

1.创建一个Project,添加hibernate的jar包。

2.添加Hibernate组件,生成hibernate.cfg.xml配置文件,选择数据源,添加需要的属性。

3.编写POJO类,并配置其与数据库中表的映射关系文件hbm.xml,当然这里可以用myeclipse的反向工程进行自动生成,建议手写以加强了解。

4.在hibernate主配置文件中加入mapping映射,指向步骤3中的配置文件。

至此配置工作基本结束,接下来进行测试:

5.程序的基本流程为:

①读取Hibernate的配置信息,生成配置实例。主要用到org.hibernate.cfg.Configuration的public Configuration()

②根据配置生成SessionFactory。主要用到了org.hibernate.cfg.Configuration的public SessionFactory buildSessionFactory()

③从SessionFactory中得到Session实例,这个很中重要,它将开启一个Session,主要用到了org.hibernate 的 SessionFactory接口的public Session openSession()

④开启一个Transaction作为准备工作

⑤进行你想要的工作(CRUD),操作POJO。

⑥提交这个事务

⑦关闭事物

⑧关闭Session

该流程大致分三个阶段:1.初始化(前三)2.真正的操作阶段(四到六)3.释放资源

建议对于第二个阶段我们可以适度的封装下,这样会比较清楚易用。